Skip to content

Instantly share code, notes, and snippets.

@hwclass
Last active August 7, 2019 13:09
Show Gist options
  • Save hwclass/66e852f0e55be8ec1acdf6e3ee76d290 to your computer and use it in GitHub Desktop.
Save hwclass/66e852f0e55be8ec1acdf6e3ee76d290 to your computer and use it in GitHub Desktop.
const currentUrl = https://blacklane.com/?maintenance_mode=on&foo=baz
function removeQueryString(currentUrl, removeThis) {
const url = new URL(currentUrl);
const query_string = url.search;
const search_params = new URLSearchParams(query_string);
search_params.delete(maintenance_mode);
url.search = search_params.toString();
return url.toString();
}
removeQueryString(currentUrl, 'maintenance_mode') // "https://blacklane.com/?foo=baz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment