Skip to content

Instantly share code, notes, and snippets.

@marqsm
Created August 26, 2019 07:38
Show Gist options
  • Save marqsm/5c491039ebc7cc378457b356e466058e to your computer and use it in GitHub Desktop.
Save marqsm/5c491039ebc7cc378457b356e466058e to your computer and use it in GitHub Desktop.
Url params to object
a.replace('?', '')
.split('&')
.reduce((accumulator, currentValue) => {
const pos = currentValue.indexOf('=');
const key = currentValue.slice(0, pos);
const value = currentValue.slice(pos+1);
accumulator[key] = value;
return accumulator;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment