Skip to content
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

Replace qs with URLSearchParams #5592

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

tomhughes
Copy link
Member

As javascript now has a builtin way to parse URL search parameters we don't really need the qs module any more, so replace it with the builtin support.

var href = link.href.split(/[?#]/)[0],
args = Qs.parse(link.search.substring(1)),
editlink = $(link).hasClass("editlink");
let href = link.href.split(/[?#]/)[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a good and correct change:

Suggested change
let href = link.href.split(/[?#]/)[0];
let href = link.protocol + '//' + link.hostname + link.pathname;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually changing that line though? Other than replacing var with let?

Copy link
Contributor

@HolgerJeromin HolgerJeromin Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the general goal was to replace complex code with modern APIs.
If this is an external library or own code is for me not important.
Both approaches (doing one single task vs bigger refactorings) have pros and cons.

@tomhughes tomhughes force-pushed the urlsearchparams branch 2 times, most recently from f288601 to 05c1f53 Compare February 2, 2025 14:55
@@ -39,7 +37,7 @@ OSM.initializeContextMenu = function (map) {
callback: function describeLocation(e) {
const [lat, lon] = OSM.cropLocation(e.latlng, map.getZoom()).map(encodeURIComponent);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encodeURIComponent here probably doesn't do anything

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but it's not something new in this pull request?

@AntonKhorev AntonKhorev merged commit 55c1033 into openstreetmap:master Feb 3, 2025
13 of 15 checks passed
@tomhughes tomhughes deleted the urlsearchparams branch February 3, 2025 10:56
tyrasd added a commit to tyrasd/openstreetmap-website that referenced this pull request Feb 12, 2025
the current version of iD (v2.31, before the fix for https://github.com/openstreetmap/iD/issue/10761: openstreetmap/iD#10766), does not fully support `x-www-form-urlencoded` "query-style" strings in the hash: Specifically, spaces encoded as `+` will not be decoded back to ` `.

This workaround essentially temporarily reverts the behaviour of the website to the state before openstreetmap#5592, and can be dropped again with the next minor version upgrade of iD (`v2.32`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants