diff --git a/server/utils/index.js b/server/utils/index.js index ff7db7a2..79b6a93a 100644 --- a/server/utils/index.js +++ b/server/utils/index.js @@ -56,12 +56,6 @@ const xmlToJSON = (xml) => { Logger.error(`[xmlToJSON] Error`, err) resolve(null) } else { - if (typeof results.package.metadata[0].meta != "undefined") { - results.package.metadata[0].meta = {} - for(var match of xml.matchAll(//g)) { - results.package.metadata[0].meta[match.groups['name']] = [match.groups['content']] - } - } resolve(results) } }) diff --git a/server/utils/parseOpfMetadata.js b/server/utils/parseOpfMetadata.js index f48603de..83f3e3cb 100644 --- a/server/utils/parseOpfMetadata.js +++ b/server/utils/parseOpfMetadata.js @@ -90,6 +90,13 @@ module.exports.parseOpfMetadataXML = async (xml) => { metadata = metadata[0] } + if (typeof metadata.meta != "undefined") { + metadata.meta = {} + for(var match of xml.matchAll(//g)) { + metadata.meta[match.groups['name']] = [match.groups['content']] + } + } + var creators = parseCreators(metadata) var data = { title: fetchTitle(metadata),