Last active
October 6, 2015 13:58
-
-
Save jcubic/3004101 to your computer and use it in GitHub Desktop.
create an object from query string
This file contains 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 query = (function() { | |
function decode(string) { | |
return decodeURIComponent(string.replace(/\+/g, " ")); | |
} | |
var result = {}; | |
if (location.search) { | |
location.search.substring(1).split('&').forEach(function(pair) { | |
pair = pair.split('='); | |
result[decode(pair[0])] = decode(pair[1]); | |
}); | |
} | |
return result; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment