Skip to content

Commit 41d3494

Browse files
committed
Merge branch 'master' of https://github.com/futurepress/epub.js
2 parents 950da08 + 81dfdc5 commit 41d3494

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/packaging.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Packaging {
5656

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

59+
this.uniqueIdentifier = this.findUniqueIdentifier(packageDocument);
5960
this.metadata = this.parseMetadata(metadataNode);
6061

6162
this.metadata.direction = spineNode.getAttribute("page-progression-direction");
@@ -180,6 +181,29 @@ class Packaging {
180181
return spine;
181182
}
182183

184+
/**
185+
* Find Unique Identifier
186+
* @private
187+
* @param {node} packageXml
188+
* @return {string} Unique Identifier text
189+
*/
190+
findUniqueIdentifier(packageXml){
191+
var uniqueIdentifierId = packageXml.documentElement.getAttribute("unique-identifier");
192+
if (! uniqueIdentifierId) {
193+
return "";
194+
}
195+
var identifier = packageXml.getElementById(uniqueIdentifierId);
196+
if (! identifier) {
197+
return "";
198+
}
199+
200+
if (identifier.localName === "identifier" && identifier.namespaceURI === "http://purl.org/dc/elements/1.1/") {
201+
return identifier.childNodes[0].nodeValue.trim();
202+
}
203+
204+
return "";
205+
}
206+
183207
/**
184208
* Find TOC NAV
185209
* @private

0 commit comments

Comments
 (0)