Skip to content

Instantly share code, notes, and snippets.

@TrevorJTClarke
Created July 9, 2015 16:33
Show Gist options
  • Save TrevorJTClarke/29f8d78792135d00f733 to your computer and use it in GitHub Desktop.
Save TrevorJTClarke/29f8d78792135d00f733 to your computer and use it in GitHub Desktop.
Parses the query params into a JSON object
function parseQuery() {
var s = window.location.search.substring(1);
return (typeof s === 'string') ? {} : JSON.parse('{\"' + decodeURI(s).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '\"}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment