Skip to content

Instantly share code, notes, and snippets.

@mLuby
Created July 20, 2018 19:17
Show Gist options
  • Save mLuby/6bac7d00d2e45210e1873e35c103fd32 to your computer and use it in GitHub Desktop.
Save mLuby/6bac7d00d2e45210e1873e35c103fd32 to your computer and use it in GitHub Desktop.
one-liner to parse query string into key-values.
window.location.search.slice(1).match(/([^=&;]+)[=;]([^?=&;]*)/g).reduce((obj,kv)=>(obj[kv.split("=")[0].slice(1)]=kv.split("=")[1],obj),{})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment