Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/futurepress/epub.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fchasen committed Oct 14, 2018
2 parents 950da08 + 81dfdc5 commit 41d3494
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/packaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Packaging {

this.spine = this.parseSpine(spineNode, this.manifest);

this.uniqueIdentifier = this.findUniqueIdentifier(packageDocument);
this.metadata = this.parseMetadata(metadataNode);

this.metadata.direction = spineNode.getAttribute("page-progression-direction");
Expand Down Expand Up @@ -180,6 +181,29 @@ class Packaging {
return spine;
}

/**
* Find Unique Identifier
* @private
* @param {node} packageXml
* @return {string} Unique Identifier text
*/
findUniqueIdentifier(packageXml){
var uniqueIdentifierId = packageXml.documentElement.getAttribute("unique-identifier");
if (! uniqueIdentifierId) {
return "";
}
var identifier = packageXml.getElementById(uniqueIdentifierId);
if (! identifier) {
return "";
}

if (identifier.localName === "identifier" && identifier.namespaceURI === "http://purl.org/dc/elements/1.1/") {
return identifier.childNodes[0].nodeValue.trim();
}

return "";
}

/**
* Find TOC NAV
* @private
Expand Down

0 comments on commit 41d3494

Please sign in to comment.