0.2.0 • Published 1 year ago

url-search-params-delete v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

url-search-params-delete

A polyfill adding support for .delete(key,value) to URLSearchParams as discussed at https://github.com/whatwg/url/issues/335

const paramsString = "foo=1&foo=2&bar=3";
const searchParams = new URLSearchParams(paramsString);
searchParams.delete("foo", "2");
console.log(searchParams.toString()); // "foo=1&bar=3"

Install the npm package url-search-params-delete and import it in your application code; a suitable location for this is usually at the top of your entry file.

import "url-search-params-delete";

The polyfill also adds support for .has(key,value) (supporting a second argument for URLSearchParams.has()).

const paramsString = "foo=1";
const searchParams = new URLSearchParams(paramsString);
searchParams.has("foo", "1"); // true
searchParams.has("foo", "2"); // false