Last active
October 16, 2021 12:34
-
-
Save sayyedhammadali/765eb65a11309b85142df1502a423075 to your computer and use it in GitHub Desktop.
Get Query Params from URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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