I noticed that value
parameter of URLSearchParams.has()
is only supported in Firefox:
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/has
Example:
// URL: https://example.com?color=orange
const searchParams = useSearchParams(); // Next.js Hook
const params = new URLSearchParams(searchParams);
// params.has(name, value)
params.has("color", "green") // Firefox correctly returns false; other browsers return true because they only check "color" and not its value.
I’m thinking of creating my own function, but is there already a polyfill for that? If yes, how can I use it (I’m using Next.js if it helps)?