Last active
November 11, 2015 18:37
-
-
Save jaawerth/31ad025e6e55bee85d40 to your computer and use it in GitHub Desktop.
simple function for parser a URL's querystring into an object of key-value pairs
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
function parse(qs) { | |
return qs.replace(/^\?/, '').split('&').reduce(function(col, pairStr) { | |
// pairStr is of form `foo=bar` | |
var pair = pairStr.split('=').map(decodeURIComponent); | |
col[pair[0]] = pair[1]; | |
return col; | |
}, {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment