-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Preserve fresh=true query param #2702
Conversation
|
||
function normalizeURL(url, pathPrefix, accessToken) { | ||
function normalizeURL(parsedUrl, pathPrefix, accessToken) { |
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.
Would this module be simpler if we parsed the url within normalizeURL
instead of within its callers?
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.
I wouldn't mind parsing the same URL twice. This code isn't very hot.
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.
I'm not sure it's helpful to modify normalizeURL
, it's already able to handle URLs with query strings. We'd only need to make sure that when URLs are manipulated before being passed to normalizeURL
propagate the query string.
If you do |
The query string should be opaque to mapbox-gl-js. If the server handling the request thinks the tile, sprite or glyph URLs should contain the query param, it can add it before responding with the style. |
tests passing, lmk how it looks! I'll squash down to one commit on merge. |
formattedQuery = '?' + querystring.stringify(urlObject.query); | ||
} | ||
|
||
var parsedURL = url.format(urlObject.protocol + '/' + urlObject.pathname + formattedQuery); |
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.
What's your intent using url.format
here? As best I can tell, this method is supposed to take an Object
argument, not a String
argument.
aa1ab07
to
16074af
Compare
Hang on -- I'm seeing some rendering defects & error messages in the console when running this branch... |
I think this is ready to 🚢 on 🍏 |
* add a fresh query param on sprites and fonts urls * lint * lint2 * empty space * parse urls * update normalizeSourceUrl * update notation * change some name to avoid overlap with url lib * make normalizeUrl normal again * parse url for source and style * clean up * empty return * spaces * get rid of fresh false * consistent naming, use Object.keys instead of getOwnPropertyNames * use url parse throughout * glyphs url too * delete repeat * get rid of url format * add a fresh query param on sprites and fonts urls * lint * lint2 * empty space * parse urls * update normalizeSourceUrl * update notation * change some name to avoid overlap with url lib * make normalizeUrl normal again * parse url for source and style * clean up * empty return * spaces * get rid of fresh false * consistent naming, use Object.keys instead of getOwnPropertyNames * use url parse throughout * glyphs url too * delete repeat * get rid of url format * Refactor for clarity and robustness * Fix normalization of composite urls
* add a fresh query param on sprites and fonts urls * lint * lint2 * empty space * parse urls * update normalizeSourceUrl * update notation * change some name to avoid overlap with url lib * make normalizeUrl normal again * parse url for source and style * clean up * empty return * spaces * get rid of fresh false * consistent naming, use Object.keys instead of getOwnPropertyNames * use url parse throughout * glyphs url too * delete repeat * get rid of url format * add a fresh query param on sprites and fonts urls * lint * lint2 * empty space * parse urls * update normalizeSourceUrl * update notation * change some name to avoid overlap with url lib * make normalizeUrl normal again * parse url for source and style * clean up * empty return * spaces * get rid of fresh false * consistent naming, use Object.keys instead of getOwnPropertyNames * use url parse throughout * glyphs url too * delete repeat * get rid of url format * Refactor for clarity and robustness * Fix normalization of composite urls
This appears to have been implemented independently for the native SDKs in mapbox/mapbox-gl-native#5554. |
For caching headers, allow
fresh=true
to be preserved and passed onto the http:// URL. This applies tomapbox://
only URLS.fixes #2699
cc @scothis @jakepruitt @emilymcafee