Skip to content

Instantly share code, notes, and snippets.

@Git-I985
Created July 8, 2023 07:27
Show Gist options
  • Save Git-I985/30f102a9c1b9ae808e1a58dec1885c1d to your computer and use it in GitHub Desktop.
Save Git-I985/30f102a9c1b9ae808e1a58dec1885c1d to your computer and use it in GitHub Desktop.
Parse query params
const getQueryParams = (str) => Object.fromEntries(Array.from(str.matchAll(/(?:([^?=&]+)=([^=&]+))/gm)).map(([_, param, value]) => [decodeURIComponent(param), decodeURIComponent(value)]))
@Git-I985
Copy link
Author

Invalid impl, does not process # (hash) in url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment