Skip to content

Instantly share code, notes, and snippets.

@MichaelSitter
Created November 8, 2013 22:56
Show Gist options
  • Save MichaelSitter/7379021 to your computer and use it in GitHub Desktop.
Save MichaelSitter/7379021 to your computer and use it in GitHub Desktop.
Simple querystring parser
define({
parse: function (querystring) {
if (querystring[0] === '?') {
querystring.substring(1, querystring.length);
}
var pairs = querystring.split('&'),
keys = {};
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=');
if (pair[0] && pair[1]) {
keys[pair[0]] = pair[1];
}
}
return keys;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment