-
Notifications
You must be signed in to change notification settings - Fork 3
feat: convert relative paths to absolute #108
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
feat: convert relative paths to absolute #108
Conversation
Thanks for the PR! Really appreciate it.
I think this is the approach I'd like to take. Since we're not creating STAC items, but loading it in from external sources, I think it's fine if we mutate-on-read to make the rest of the app "simple" (rather than having to repeatedly "resolve" relative urls). |
If your happy with mutating the documents, that would be a better approach, Are you ok if I leave properties alone and only touch objects with |
Yep, I think links and assets are everything we need to do for now. Appreciate it! |
adb5448
to
eaef7d6
Compare
@gadomski I have swapped across to converting the stac document when it is fetched, I have used A more comprehensive external lib like uri-js may be better suited for the advanced joins, or possibly just ignoring non http(s?) URLS would be the best approach? |
Thanks for iterating, and for adding tests!
I'd be more in favor of using an external lib. While s3 urls aren't supported for direct loading now, I'd like to be able to point the app at s3 at some point down the road. |
The current logic handles S3 URLs, however the STAC document would need to be loaded from a S3 URL for the logic to trigger, I am not sure how relevant that is for a client side library, unless your providing credentials to the client then it would be better to use HTTP access? If in the future other source protocols are added that need specialised encoding, ideally you would want to use a specific URL parser/joiner per protocol. With the current logic: If the links inside the document are absolute, no changes are applied. If the links inside the document are relative:
|
Yup, this is the long-term idea, very much in the future at this point. Thanks for talking through things, I'll review. |
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.
Just a couple small tweaks, but in general looks great!
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
🎉 This PR is included in version 0.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Motivation
Most of LINZ's STAC items and collections are relative links as to make it easier to move them around, we have a long term goal of converting them all to absolute links but that is going to take a way.
In the mean time it would be great if this map tool supported relative links and assets.
Modification
I have added a symbol to all items that have been fetched via the
fetchStac
to store their source location onto the STAC document, so then any URL referenced from the document can converted with the source URL.I tried to avoid mutating the stac documents as I wasn't sure of the imapct, so I avoided these two other ideas