Skip to content

Emptying URLSearchParams causes unwanted "?" char #10480

Closed

Description

@stevenvachon
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.

Activity

  1. stevenvachon commented on Dec 28, 2016

    @stevenvachon
    Author
  2. added
    url
    on Dec 28, 2016
  3. self-assigned this
    on Dec 28, 2016
  4. targos commented on Dec 28, 2016

    @targos
    Member

    Proposed fix: #10486

  5. added
    whatwg-url
    on Jan 23, 2017
  6. removed their assignment
    on Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    urlwhatwg-url

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions