-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor HREF normalization and models #387
Conversation
72c3027
to
35f00bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For backward compatibility, I would introduce a normalization from previous absolute URL-based locators to the new ones, based on hrefs directly provided by manifests.
readium/shared/src/main/java/org/readium/r2/shared/resource/Container.kt
Outdated
Show resolved
Hide resolved
Yes, this is done in #388 kotlin-toolkit/readium/navigator/src/main/java/org/readium/r2/navigator/extensions/Publication.kt Lines 26 to 52 in d7540ed
|
PR Analysis
PR Feedback
How to use
|
# Conflicts: # readium/lcp/src/main/java/org/readium/r2/lcp/license/container/ContainerLicenseContainer.kt # readium/lcp/src/main/java/org/readium/r2/lcp/license/container/FileZipLicenseContainer.kt # readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LcplLicenseContainer.kt # readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LcplResourceLicenseContainer.kt # readium/lcp/src/main/java/org/readium/r2/lcp/license/container/LicenseContainer.kt # readium/shared/src/main/java/org/readium/r2/shared/publication/services/content/iterators/HtmlResourceContentIterator.kt # test-app/src/main/java/org/readium/r2/testapp/bookshelf/BookRepository.kt # test-app/src/main/java/org/readium/r2/testapp/catalogs/CatalogViewModel.kt
9fe0d30
to
e840fc0
Compare
Changes in the HREF normalization strategy
The goal is to improve the interoperability of stored HREF with other platforms.
Manifest
parser doesn't normalize HREFs to the base URL anymore./
anymore. They are relative to the root of the archive./
.Refactoring of
Href
andUrl
Various refactoring to improve the safety and reliability of URLs and Link HREFs.
Rationale
Changes
Url
sealed class with two implementationsAbsoluteUrl
andRelativeUrl
.AbsoluteUrl
offers helpers to check the URL scheme and convert to/from aFile
.Href()
normalization strategy.Url
is always percent-encoded. We can encode a relative path (e.g. a ZIP entry name) withUrl.fromDecodedPath()
.util.Href
doesn't exist anymore. There's apublication.Href
which can be either a URI template, or a validUrl
. It is used inLink
objects.Link
andLocator
exposeUrl
andHref
instead of raw strings.self
or the feed URL. I added some kind of Visitor to modify theManifest
to normalize the HREFs (ManifestTransformer
).