Created
April 6, 2016 03:29
-
-
Save MatthewDaniels/9f84f5b17a46621b88508c6bef083995 to your computer and use it in GitHub Desktop.
Parse the current window location's query parameters into a map
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 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