We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Looks like you can probably just do something like this:
const foo = "https://prettier.io/docs/en/options.html?foo=true&utm_foo=true&utm_bar=false&bar=false&x=7"; console.log(deUtm(foo)); function deUtm(href) { const url = new URL(href); for (const key of [...url.searchParams.keys()]) { key.startsWith("utm_") && url.searchParams.delete(key); } return url.href; }
$ node de-utm.js # INPUT: https://prettier.io/docs/en/options.html?foo=true&utm_foo=true&utm_bar=false&bar=false&x=7 # OUTPUT: https://prettier.io/docs/en/options.html?foo=true&bar=false&x=7
Probably easiest/fastest to do in a single for..of loop vs trying to do a less efficient .filter().forEach() double loop, a la:
for..of
.filter().forEach()
// WARNING: SUBOPTIMAL DOUBLE LOOP const url = new URL(href); [...url.searchParams.keys()] .filter(key => key.startsWith("utm_")) .forEach(key => url.searchParams.delete(key)); return url.href;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Looks like you can probably just do something like this:
Probably easiest/fastest to do in a single
for..of
loop vs trying to do a less efficient.filter().forEach()
double loop, a la:The text was updated successfully, but these errors were encountered: