Skip to content

Commit 16c37f0

Browse files
authored
Fix selection of EPUB unique identifier (#85)
1 parent f807756 commit 16c37f0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

readium/streamer/src/main/java/org/readium/r2/streamer/parser/epub/Metadata.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,11 @@ internal class PubMetadataAdapter(
196196
val identifier: String?
197197

198198
init {
199-
val identifiers = items[Vocabularies.DCTERMS + "identifier"]
200-
?.associate { Pair(it.property, it.value) }.orEmpty()
199+
val identifiers = items[Vocabularies.DCTERMS + "identifier"].orEmpty()
201200

202-
identifier = uniqueIdentifierId?.let { identifiers[it] } ?: identifiers.values.firstOrNull()
201+
identifier = uniqueIdentifierId
202+
?.let { uniqueId -> identifiers.firstOrNull { it.id == uniqueId }?.value }
203+
?: identifiers.firstOrNull()?.value
203204
}
204205

205206
val published = firstValue(Vocabularies.DCTERMS + "date")?.iso8601ToDate()

readium/streamer/src/test/resources/org/readium/r2/streamer/parser/epub/package/identifier-unique.opf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
44
<dc:title>Alice's Adventures in Wonderland</dc:title>
55
<dc:identifier> </dc:identifier>
6-
<dc:identifier id="isbn">978-3-16-148410-0</dc:identifier>
6+
<dc:identifier>BEQ</dc:identifier>
77
<dc:identifier id="pub-id">urn:uuid:2</dc:identifier>
8+
<dc:identifier id="isbn">978-3-16-148410-0</dc:identifier>
89
</metadata>
910
<manifest>
1011
<item id="titlepage" href="titlepage.xhtml" media-type="application/xhtml+xml" />

0 commit comments

Comments
 (0)