Merge pull request #12993 from Snuffleupagus/metadata-subject
[api-minor] Change the `dc:subject` Metadata field to an Array
This commit is contained in:
commit
b5735f2017
@ -89,23 +89,18 @@ class Metadata {
|
|||||||
return entry.childNodes.filter(node => node.nodeName === "rdf:li");
|
return entry.childNodes.filter(node => node.nodeName === "rdf:li");
|
||||||
}
|
}
|
||||||
|
|
||||||
_getCreators(entry) {
|
_parseArray(entry) {
|
||||||
if (entry.nodeName !== "dc:creator") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!entry.hasChildNodes()) {
|
if (!entry.hasChildNodes()) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Child must be a Bag (unordered array) or a Seq.
|
// Child must be a Bag (unordered array) or a Seq.
|
||||||
const seqNode = entry.childNodes[0];
|
const [seqNode] = entry.childNodes;
|
||||||
const authors = this._getSequence(seqNode) || [];
|
const sequence = this._getSequence(seqNode) || [];
|
||||||
|
|
||||||
this._metadataMap.set(
|
this._metadataMap.set(
|
||||||
entry.nodeName,
|
entry.nodeName,
|
||||||
authors.map(node => node.textContent.trim())
|
sequence.map(node => node.textContent.trim())
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_parse(xmlDocument) {
|
_parse(xmlDocument) {
|
||||||
@ -130,11 +125,13 @@ class Metadata {
|
|||||||
|
|
||||||
for (const entry of desc.childNodes) {
|
for (const entry of desc.childNodes) {
|
||||||
const name = entry.nodeName;
|
const name = entry.nodeName;
|
||||||
if (name === "#text") {
|
switch (name) {
|
||||||
continue;
|
case "#text":
|
||||||
}
|
continue;
|
||||||
if (this._getCreators(entry)) {
|
case "dc:creator":
|
||||||
continue;
|
case "dc:subject":
|
||||||
|
this._parseArray(entry);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
this._metadataMap.set(name, entry.textContent.trim());
|
this._metadataMap.set(name, entry.textContent.trim());
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ describe("metadata", function () {
|
|||||||
"dc:creator": [""],
|
"dc:creator": [""],
|
||||||
"dc:description": "",
|
"dc:description": "",
|
||||||
"dc:format": "application/pdf",
|
"dc:format": "application/pdf",
|
||||||
"dc:subject": "",
|
"dc:subject": [],
|
||||||
"dc:title": "",
|
"dc:title": "",
|
||||||
"pdf:keywords": "",
|
"pdf:keywords": "",
|
||||||
"pdf:pdfversion": "1.7",
|
"pdf:pdfversion": "1.7",
|
||||||
|
Loading…
Reference in New Issue
Block a user