-
Notifications
You must be signed in to change notification settings - Fork 113
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
JSON Locator not parsing Fragments correctly #263
Comments
I'm not sure I see where the discrepancy is with the Kotlin toolkit, the As for your use case (I read the original issue), it looks like you are trying to parse a
Or more directly, use |
@mickael-menu thanks for educating me and sorry for being a n00b. In general, is there some documentation I can read about the differences between Links and Locators and how and when they're used? Specifically, how do I know the difference between them from a JSON representation? I had read through this and naively assumed that's all there was to it. I haven't been able to find any docs on Links. Thanks in advance! |
You can read the specification of the This PR describes use cases for locators, but it was never merged. |
@mickael-menu thanks again! This is super helpful. When looking at the schemas it looks like if an object doesn't have any Thanks again! |
Technically this JSON could both be a Link object or a Locator : {
"href": "resource.xhtml",
"type": "application/xhtml+xml"
} So you should look at each API or JSON schema/specification to know what to expect. With the native Kotlin/Swift APIs it's easy as it's fully typed. With JavaScript you might need to look into the JSON schemas. |
@mickael-menu ahh, I see. Thanks. One final question: Do locators completely subsume links? For instance, I could just convert all links into locators for the TOC and return those and then only ever deal in Locators. It seems like that could be possible. |
You couldn't because a table of contents can be a tree, thanks to |
Ahh, unfortunate, but that makes sense. Thanks again! |
Bug Report
It appears that this libraries
Locator
isn't automatically parsing#
's in hrefs and adding them as fragments to theLocator
objects locations. I'd also like to note that thekotlin-toolkit
seems to be doing this fine.What happened?
If you pass a JSON object like the one below to the
Locator
constructor you will not be properly navigated to it, as the fragment isn't parsed.Expected behavior
It seems like for consistency with
kotlin-toolkit
we should be parsing those fragments and adding them automatically. Perhaps similar to how the deprecatedLink
constructor is doing it.How to reproduce?
Locator
object out of the above JSON object.Locator
tonavigator.go
.Environment
Testing device
Locator
object out of the above JSON object.2. Build aLocator
object out of the above JSON object.Locator
tonavigator.go
.Environment### Environment
Testing device#### Testing device
Additional Context
I found this issue while working this one 5-stones/react-native-readium#11 (comment). You can read that if you want some more context.
The text was updated successfully, but these errors were encountered: