-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Allow for relative paths when loading RTL plugin #6764
Conversation
src/source/rtl_text_plugin.js
Outdated
const a = window.document.createElement('a'); | ||
a.href = path; | ||
return a.href; | ||
}; |
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.
Looks like we're doing something similar in
mapbox-gl-js/src/source/geojson_source.js
Lines 288 to 292 in 6255e9e
function resolveURL(url) { | |
const a = window.document.createElement('a'); | |
a.href = url; | |
return a.href; | |
} |
Can we move that code to a more central place to avoid duplicating it?
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.
Ah thanks for pointing that out. Yeah, we should be able to centralize this somewhere.
src/source/rtl_text_plugin.js
Outdated
const resolvePluginUrl = (path) => { | ||
if (isAbsoluteUrl(path)) { | ||
return path; | ||
} |
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.
Do we need to special case absolute URLs? It looks like we could also just happily pipe absolute/protocol-relative URLs through the a
/href
resolver. If we need this, it'd be a good idea to add the absolute URL special case to the GeoJSON resolver (see below) as well)
I'm not sure how to test this other than manually. There's no straightforward way to test this in the unit tests since Node doesn't have an |
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.
@ChrisLoer can correct me if I'm wrong, but I believe we've been relying on manual testing for the RTL plugin.
Mainly, yes, and I think testing manually with csp.html is probably the most important/effective test for this pathway. The style unit test has a "register plugin listener" test case that could easily be modified to test the handling of a relative path -- but as @ryanhamley pointed out that gets tripped up on not having a Thanks for fixing this, Ryan! |
9fab797
to
7c95198
Compare
Launch Checklist
Closes #6719