Skip to content

Instantly share code, notes, and snippets.

@subhaze
Last active September 5, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subhaze/27b70066898580d30dc49414c9be87f4 to your computer and use it in GitHub Desktop.
Save subhaze/27b70066898580d30dc49414c9be87f4 to your computer and use it in GitHub Desktop.
Parse Query Params
export const queryParams = (locationSearch = window.location.search) =>
locationSearch
.substr(1)
.split('&')
.reduce(
(acc, curr) =>
Object.assign(
acc, curr
.split('=')
.reduce((acc, curr) => ({ [acc]: _decodeURIComponent(curr) })),
)
, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment