Repository navigation
Select a single value from XMP language alternatives #21999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,64 @@ describe("metadata", function () { | |
| expect([...metadata]).toEqual([["dc:title", "Foo bar baz"]]); | ||
| }); | ||
|
|
||
| it("should select the default language alternative (issue 20801)", function () { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this test and the others, make sure we've a way to know what's failing exactly (in case something is failing) in using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, each assertion now has a context with the property name and the input. |
||
| for (const name of [ | ||
| "dc:title", | ||
| "dc:description", | ||
| "dc:rights", | ||
| "xmpRights:UsageTerms", | ||
| ]) { | ||
| for (const alternatives of [ | ||
| '<rdf:li xml:lang="x-default">Hello World</rdf:li>' + | ||
| '<rdf:li xml:lang="en">Hello World</rdf:li>', | ||
| '<rdf:li xml:lang="fr">Bonjour le monde</rdf:li>' + | ||
| '<rdf:li xml:lang="x-default">Hello World</rdf:li>', | ||
| '<rdf:li xml:lang="fr">Bonjour le monde</rdf:li>' + | ||
| '<rdf:li xml:lang="X-Default">Hello World</rdf:li>', | ||
| ]) { | ||
| const data = | ||
| "<rdf:RDF><rdf:Description>" + | ||
| `<${name}><rdf:Alt>${alternatives}</rdf:Alt></${name}>` + | ||
| "</rdf:Description></rdf:RDF>"; | ||
|
|
||
| expect(createMetadata(data).get(name.toLowerCase())) | ||
| .withContext(`${name}: ${alternatives}`) | ||
| .toEqual("Hello World"); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it("should use the first language alternative if there is no default", function () { | ||
| for (const name of [ | ||
| "dc:title", | ||
| "dc:description", | ||
| "dc:rights", | ||
| "xmpRights:UsageTerms", | ||
| ]) { | ||
| const data = | ||
| "<rdf:RDF><rdf:Description>" + | ||
| `<${name}><rdf:Alt>` + | ||
| '<rdf:li xml:lang="en">Hello World</rdf:li>' + | ||
| '<rdf:li xml:lang="fr">Bonjour le monde</rdf:li>' + | ||
| `</rdf:Alt></${name}>` + | ||
| "</rdf:Description></rdf:RDF>"; | ||
|
|
||
| expect(createMetadata(data).get(name.toLowerCase())) | ||
| .withContext(name) | ||
| .toEqual("Hello World"); | ||
| } | ||
| }); | ||
|
|
||
| it("should handle whitespace before the language alternatives", function () { | ||
| const data = | ||
| "<rdf:RDF><rdf:Description><dc:title>\n <rdf:Alt>\n" + | ||
| ' <rdf:li xml:lang="en">English title</rdf:li>\n' + | ||
| ' <rdf:li xml:lang="x-default"> Default title </rdf:li>\n' + | ||
| "</rdf:Alt>\n</dc:title></rdf:Description></rdf:RDF>"; | ||
|
|
||
| expect(createMetadata(data).get("dc:title")).toEqual("Default title"); | ||
| }); | ||
|
|
||
| it("should repair and handle invalid metadata", function () { | ||
| const data = | ||
| "<x:xmpmeta xmlns:x='adobe:ns:meta/'>" + | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the XMP specs,
dc:rightsandxmpRights:UsageTermshas a language alternative too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added both.