Skip to content

Commit da09367

Browse files
committed
Allow a RWPM without a self link
1 parent 0ea3211 commit da09367

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

readium/streamer/src/main/java/org/readium/r2/streamer/ParserAssetFactory.kt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.readium.r2.shared.util.mediatype.FormatRegistry
2727
import org.readium.r2.shared.util.mediatype.MediaType
2828
import org.readium.r2.shared.util.mediatype.MediaTypeRetriever
2929
import org.readium.r2.streamer.parser.PublicationParser
30+
import timber.log.Timber
3031

3132
internal class ParserAssetFactory(
3233
private val httpClient: HttpClient,
@@ -76,22 +77,22 @@ internal class ParserAssetFactory(
7677
}
7778
.getOrElse { return Try.failure(it) }
7879

79-
val baseUrl =
80-
manifest.linkWithRel("self")?.href?.resolve()
81-
?: return Try.failure(
82-
Publication.OpenError.InvalidAsset("No self link in the manifest.")
80+
val baseUrl = manifest.linkWithRel("self")?.href?.resolve()
81+
if (baseUrl == null) {
82+
Timber.w("No self link found in the manifest at ${asset.resource.source}")
83+
} else {
84+
if (baseUrl !is AbsoluteUrl) {
85+
return Try.failure(
86+
Publication.OpenError.InvalidAsset("Self link is not absolute.")
8387
)
84-
85-
if (baseUrl !is AbsoluteUrl) {
86-
return Try.failure(
87-
Publication.OpenError.InvalidAsset("Self link is not absolute.")
88-
)
89-
}
90-
91-
if (!baseUrl.isHttp) {
92-
return Try.failure(
93-
Publication.OpenError.UnsupportedAsset("Self link doesn't use the HTTP(S) scheme.")
94-
)
88+
}
89+
if (!baseUrl.isHttp) {
90+
return Try.failure(
91+
Publication.OpenError.UnsupportedAsset(
92+
"Self link doesn't use the HTTP(S) scheme."
93+
)
94+
)
95+
}
9596
}
9697

9798
val container =

0 commit comments

Comments
 (0)