Created
October 12, 2012 10:37
-
-
Save Xophmeister/3878629 to your computer and use it in GitHub Desktop.
Deserialise the query string in JavaScript
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
if (!window.query) { | |
(function () { | |
var match, | |
search = /([^&=]+)=?([^&]*)/g, | |
decode = function (s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }, | |
query = window.location.search.substring(1); | |
window.query = {}; | |
while (match = search.exec(query)) { | |
window.query[decode(match[1])] = decode(match[2]); | |
} | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on http://stackoverflow.com/a/2880929/876937