Skip to content

Instantly share code, notes, and snippets.

@MatthewDaniels
Created April 6, 2016 03:29
Show Gist options
  • Save MatthewDaniels/9f84f5b17a46621b88508c6bef083995 to your computer and use it in GitHub Desktop.
Save MatthewDaniels/9f84f5b17a46621b88508c6bef083995 to your computer and use it in GitHub Desktop.
Parse the current window location's query parameters into a map
function parseQueryString() {
var query = (window.location.search || '?').substr(1),
map = {};
query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function(match, key, value) {
(map[key] = map[key] || []).push(value);
});
return map;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment