Skip to content

Instantly share code, notes, and snippets.

@addisaden
Last active September 3, 2015 10:02
Show Gist options
  • Save addisaden/9f1bcb969fa8707517ac to your computer and use it in GitHub Desktop.
Save addisaden/9f1bcb969fa8707517ac to your computer and use it in GitHub Desktop.
// window.location.toString() => "http://localhost:7777/?search=bla+bli+blubb+%40+%22wababab+%26%2B13%22"
var b = {};
window.location.search.replace(/^\?/, "")
.split("&")
.map(function(e) {
var r = e.match(/([^=]+)=(.+)/);
return r ? [decodeURIComponent(r[1]), decodeURIComponent(r[2].replace(/\+/g, " "))] : [null, null];
})
.map(function(x) { b[x[0]] = x[1]; });
b // = { search: "bla bli blubb @ "wababab &+13"" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment