Last active
February 15, 2018 14:20
-
-
Save wholypantalones/d69f61afb9c3c9fcdaa31e61be1ddcea to your computer and use it in GitHub Desktop.
Convert params to object
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
var search = window.location.search // ?param1=value1¶m2=value2 | |
search?JSON.parse('{"' + search.replace(/\?/g, '').replace(/&/g, '","').replace(/=/g,'":"') + '"}', | |
function(key, value) { return key===""?value:decodeURIComponent(value) }):{}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment