Skip to content

Instantly share code, notes, and snippets.

@david-hodgetts
Last active August 29, 2015 14:26
Show Gist options
  • Save david-hodgetts/1904ef27615a3af1e797 to your computer and use it in GitHub Desktop.
Save david-hodgetts/1904ef27615a3af1e797 to your computer and use it in GitHub Desktop.
quick and dirty function to parse query string
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