-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Fix URL parsing in normalizeSpriteURL #4962
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4962 +/- ##
==========================================
+ Coverage 88.95% 89.12% +0.17%
==========================================
Files 269 269
Lines 38271 38272 +1
Branches 2369 2355 -14
==========================================
+ Hits 34044 34111 +67
+ Misses 3219 3148 -71
- Partials 1008 1013 +5 ☔ View full report in Codecov by Sentry. |
Oh, do I need to re-build docs & commit, or does the CI do that somewhere? |
Thanks for taking the time to open this PR! |
It's hard to spot through the diffs, but this does preserve the usage of |
Oh, just re-read your question and see I misunderstood. Yes, I think this is the only solution here. On the net, we remove one breaking change (the re-ordering of normalizeSpriteURL and transformRequest), for another (requiring URLs to be absolute, and directing developers to correct the issue as needed). Half my time on this PR was just spent reading and cross-referencing the related issues / PRs and this is the absolute least invasive solution I came up with. |
I see the problem and i didn't know signed URls were a thing. An other solution could be to add an additional transform request. I expected transformRequest to be able to handle relative URLs before they get validated and for the signing URLs usecase the URLS should be absolute, validated and the extension .json/.png should be appended. Calling transofrm request before normalizeSpriteURL with type "Sprite" and 2 times after the normalisation with "SpriteImage" & "SpriteJSON" could be an other Option. Shouldn't break existing code and gives the flexibilty to transform all Requests before the url gets Normalized. |
@Kai-W I'm not sure I fully understand what you suggest. |
@Kai-W I considered that approach, but making multiple calls with the same URL could just as easily cause issues for developers who choose to implement non-idempotent callbacks for |
Sure, you can create a different PR for style transform, I'll need to see the ergonomics around it to decide if it makes sense, and what would happen when you set both this transform and pass a function to But let's close on this PR first. What is the current status? Can you guys agree on the needed solution? |
@jcary741 solution works for me and an additionale PR for a persisted transformStyle sounds good as well |
This is not a breaking change to version 4, right? Just a breaking version between the pre-releases...? |
It's breaking between pre-releases, but not with version 4. It does make the requirement for sprite URLs to be absolute (post transformStyle) explicit, but I don't think that worked previously anyway based on #182. |
@Kai-W any objections to merge this? |
no objections, works for me |
Launch Checklist
CHANGELOG.md
under the## main
section.Related issues: #3897, #182, #4950
Related PRs: #3898, #3923, #645
This PR reverts #3898, which introduces issues with use cases where
transformRequest()
is used for URL signing (see #4950). It also disallows relative URLs for sprite URLs moving forward. However, since #182 and #3897 were opened, transformStyleFunction has been introduced (back in 2022), which can be used by developers to pre-transform relative URLs to whatever is most appropriate. Notably, this can support both 1) ArcGIS Vector Tile Style -style relative URLs at a separate domain than the map is being used from, and 2) relative URLs hosted at the same domain as the map. This PR adds examples for how to usetransformStyle
to make URLs absolute. I don't think it is exhaustive, but definitely covers the ArcGIS Vector Tile Style cases.Also,
normalizeSpriteURL()
now also throws a detailed error message to guide developers how to solve the issue.