Skip to content

Instantly share code, notes, and snippets.

@gabemeola
Created July 5, 2018 18:00
Show Gist options
  • Save gabemeola/11aec9564955c17509c758ec93b77163 to your computer and use it in GitHub Desktop.
Save gabemeola/11aec9564955c17509c758ec93b77163 to your computer and use it in GitHub Desktop.
Safe Version of URLSearchParams to use with Microsoft Edge: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/18156339/
class SafeURLSearchParams extends URLSearchParams {
static isGarbageBrowser = (() => {
try {
new URLSearchParams(new URLSearchParams('a=a'));
return false;
} catch (e) {
return true;
}
})()
constructor(init) {
if (SafeURLSearchParams.isGarbageBrowser && init instanceof URLSearchParams) {
init = init.toString();
}
super(init);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment