Last active
August 29, 2015 14:26
-
-
Save david-hodgetts/1904ef27615a3af1e797 to your computer and use it in GitHub Desktop.
quick and dirty function to parse query string
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 parseQuery = function(queryString){ | |
var possibleMatches = queryString.replace(/ /g,'').split('&'), | |
regex = /(\w+)=(\w+)/; | |
return possibleMatches.reduce(function(array, current){ | |
var match = regex.exec(current); | |
if(match){ | |
array.push({ | |
key: match[1], | |
value: match[2] | |
}); | |
} | |
return array; | |
}, []); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment