Skip to content

Instantly share code, notes, and snippets.

@sayyedhammadali
Last active October 16, 2021 12:34
Show Gist options
  • Save sayyedhammadali/765eb65a11309b85142df1502a423075 to your computer and use it in GitHub Desktop.
Save sayyedhammadali/765eb65a11309b85142df1502a423075 to your computer and use it in GitHub Desktop.
Get Query Params from URL
const getParameters = (URL) => JSON.parse('{"' + decodeURI(URL.split("?")[1]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') +'"}');
getParameters("https://www.google.de/search?q=cars&start=40");
// Result: { q: 'cars', start: '40' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment