-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
URL: ensure deleting all params keeps ? in URL #6445
Conversation
Firefox (nightly)Testing web-platform-tests at revision da797a5 All results1 test ran/url/urlsearchparams-delete.html
|
Sauce (safari)Testing web-platform-tests at revision da797a5 |
Chrome (unstable)Testing web-platform-tests at revision da797a5 |
Sauce (MicrosoftEdge)Testing web-platform-tests at revision da797a5 |
It might be worth changing this given what browsers do. It does seem a little cleaner. |
@annevk I'll check what Edge does. It is cleaner, but less consistent with the fact that generally the update step is equivalent to |
Deleting non existing param gives different behavior on browsers
let url = new URL("http://ex.com/?");
console.log(`Before Delete: ${url.toString()}`)
url.searchParams.delete('NotPresent');
console.log(`After Delete: ${url.toString()}`) This behavior is again inconsistent on Firefox's current behavior. |
Indeed. And Edge apparently does not support the |
Okay, I guess I'm good either way. Anyone up for filing browser bugs? |
I think it makes most sense to remove the "?" delimiter. By changing any param, the URL has been mutated and needn't preserve the delimiter. URLs with and without such are considered the same, anyway. @TimothyGu Safari 10.1.1 doesn't have |
@stevenvachon What do you think about the case in #6445 (comment)? Specifically, in Chrome, there is a case when no param is actually changed but the URL is still mutated. This just doesn't sit well with me. In my opinion the current spec behavior is still the most consistent. |
Deleting a non-existent param isn't technically a mutation, but it had the intent of such. We could always check before deleting. |
'?' should be present in URL only when there is at least one QP makes sense. new URL('http://w.co/?').toString() == new URL('http://w.co/').toString() |
Also, when we parse |
This is a dangerous assumption. In fact it goes against what ALL implementations of URLs are doing today and the last few decades. If the spec is to be changed this way, this would mean that it would be impossible to visit a website like Plus, we have to be careful to avoid slippery slope here. By this token, one could argue that a trailing
This is true. However, we should not conflate URL-level concepts with
The older RFC 2396 defines query as:
Based on these definitions, there is surely a difference between an empty query component and an undefined query component, a distinction reaffirmed by the URL Standard. |
I agree, but |
I don't see how base URL handling for |
@annevk I don't understand your comment. By "base URL", are you referring to |
I meant that if |
Oops, I typo'ed. Comment edited. |
I still don't understand what you're trying to say. Anyway, if you want to advocate some kind of change I recommend raising an issue against whatwg/url so we can consider it standalone. It shouldn't block this PR. My bad for taking in that direction to begin with. |
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 you want me to file the bugs @TimothyGu?
We could end up with a bigger issue if browsers need to be re-patched. |
@annevk Sure, go ahead. |
Safari TP already passes. Bugs: |
Changes outcome of test added in #6445. Tests for whatwg/url#336.
Changes outcome of test added in #6445. Tests for whatwg/url#336.
See jsdom/whatwg-url#97.