logoalt Hacker News

susamtoday at 7:15 AM0 repliesview on HN

This corrupts a URL like:

  https://example.com/?p=20&utm_source=spam
to:

  https://example.com/
when in fact we want the following:

  https://example.com/?p=20
A possible improvement can be:

  javascript:(()=>{const u=new URL(location.href);[...u.searchParams.keys()].forEach(k=>{if(k.startsWith('utm_')){u.searchParams.delete(k)}});navigator.clipboard.writeText(u.href)})();