Skip to content

Instantly share code, notes, and snippets.

@Blumed
Last active April 18, 2017 04:56
Show Gist options
  • Save Blumed/208b6f654460639a5cd2ac502693eaff to your computer and use it in GitHub Desktop.
Save Blumed/208b6f654460639a5cd2ac502693eaff to your computer and use it in GitHub Desktop.
Create a query directory object out of a url.
//https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript?page=1&tab=active#tab-top
let qd = {};
if (location.href) {
let re = /(\#|\&)/;
location.href.substr(1).split(re).forEach(item => {let [k,v] = item.split("="); v = v && decodeURIComponent(v).replace(/\+/g, " "); (qd[k] = qd[k] || []).push(v)})
}
//type qd into console to see all of the arrays created by script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment