From 4ac0bd6770912d904c38ed84fe3647532e227c16 Mon Sep 17 00:00:00 2001 From: Igor Kaldowski Date: Sat, 4 Dec 2021 22:15:23 +0000 Subject: [PATCH] Moved getting xml meta entries to opf parser --- server/utils/index.js | 6 ------ server/utils/parseOpfMetadata.js | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) 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),