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

Emptying URLSearchParams causes unwanted "?" char #10480

Closed
stevenvachon opened this issue Dec 28, 2016 · 2 comments
Closed

Emptying URLSearchParams causes unwanted "?" char #10480

stevenvachon opened this issue Dec 28, 2016 · 2 comments
Labels
url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Comments

@stevenvachon
Copy link

const url = new URL("http://domain?var=1&var=2&var=3");
const params = Array.from(url.searchParams);

// There is no `.clear()`
for (let param of url.searchParams) {
  url.searchParams.delete( param[0] );
}

console.log(url.href) //-> http://domain/?

url.search = url.searchParams.toString();

console.log(url.href) //-> http://domain/

Tested in Chrome and both correctly log the same (second) value.

@stevenvachon
Copy link
Author

@TimothyGu @jasnell

@mscdex mscdex added the url Issues and PRs related to the legacy built-in url module. label Dec 28, 2016
@targos targos self-assigned this Dec 28, 2016
@targos
Copy link
Member

targos commented Dec 28, 2016

Proposed fix: #10486

targos added a commit to targos/node that referenced this issue Jan 1, 2017
If searchParams becomes empty, query must be set to null.
Add missing update of context flags.

Fixes: nodejs#10480
PR-URL: nodejs#10486
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this issue Jan 3, 2017
If searchParams becomes empty, query must be set to null.
Add missing update of context flags.

Fixes: #10480
PR-URL: #10486
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this issue Jan 4, 2017
If searchParams becomes empty, query must be set to null.
Add missing update of context flags.

Fixes: #10480
PR-URL: #10486
Reviewed-By: James M Snell <jasnell@gmail.com>
@TimothyGu TimothyGu added the whatwg-url Issues and PRs related to the WHATWG URL implementation. label Jan 23, 2017
@targos targos removed their assignment Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

No branches or pull requests

4 participants