Created
July 5, 2018 18:00
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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