Skip to content

Instantly share code, notes, and snippets.

@Xophmeister
Created October 12, 2012 10:37
Show Gist options
  • Save Xophmeister/3878629 to your computer and use it in GitHub Desktop.
Save Xophmeister/3878629 to your computer and use it in GitHub Desktop.
Deserialise the query string in JavaScript
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]);
}
})();
}
@Xophmeister
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment