Skip to content

Instantly share code, notes, and snippets.

@agusputra
Last active September 9, 2020 05:04
Show Gist options
  • Select an option

  • Save agusputra/bab0241c41c187e79b10 to your computer and use it in GitHub Desktop.

Select an option

Save agusputra/bab0241c41c187e79b10 to your computer and use it in GitHub Desktop.
parseQueryString
export function parseQueryString() {
const qs = decodeURIComponent(window.location.search.substring(1)).split('&');
const result = {};
for (const i in qs) {
if (Object.prototype.hasOwnProperty.call(qs, i)) {
const keyValue = qs[i].split('=');
result[keyValue[0]] = keyValue[1];
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment