diff --git a/src/display/metadata.js b/src/display/metadata.js index 54ff9f7c2af1f..4b6c4b74fe41d 100644 --- a/src/display/metadata.js +++ b/src/display/metadata.js @@ -89,23 +89,18 @@ class Metadata { return entry.childNodes.filter(node => node.nodeName === "rdf:li"); } - _getCreators(entry) { - if (entry.nodeName !== "dc:creator") { - return false; - } + _parseArray(entry) { if (!entry.hasChildNodes()) { - return true; + return; } - // Child must be a Bag (unordered array) or a Seq. - const seqNode = entry.childNodes[0]; - const authors = this._getSequence(seqNode) || []; + const [seqNode] = entry.childNodes; + const sequence = this._getSequence(seqNode) || []; + this._metadataMap.set( entry.nodeName, - authors.map(node => node.textContent.trim()) + sequence.map(node => node.textContent.trim()) ); - - return true; } _parse(xmlDocument) { @@ -130,11 +125,13 @@ class Metadata { for (const entry of desc.childNodes) { const name = entry.nodeName; - if (name === "#text") { - continue; - } - if (this._getCreators(entry)) { - continue; + switch (name) { + case "#text": + continue; + case "dc:creator": + case "dc:subject": + this._parseArray(entry); + continue; } this._metadataMap.set(name, entry.textContent.trim()); } diff --git a/test/unit/metadata_spec.js b/test/unit/metadata_spec.js index 7d6b0d3246bdd..557e957bbb6aa 100644 --- a/test/unit/metadata_spec.js +++ b/test/unit/metadata_spec.js @@ -171,7 +171,7 @@ describe("metadata", function () { "dc:creator": [""], "dc:description": "", "dc:format": "application/pdf", - "dc:subject": "", + "dc:subject": [], "dc:title": "", "pdf:keywords": "", "pdf:pdfversion": "1.7",