Open better2021 opened 4 years ago
function getUrlParams(url) { var search = url.split('?')[1] if (!search) { return {} } return JSON.parse( '{"' + decodeURIComponent(search) .replace(/"/g, '\\"') .replace(/&/g, '","') .replace(/=/g, '":"') .replace(/\+/g, ' ') + '"}' ) } // var url = search?q=dsd&oq=dsd&aqs=chrome..69i57j0l7.642j0j15&sourceid=chrome&ie=UTF-8 // JSON.stringify(getUrlParams(url )) // "{"q":"dsd","oq":"dsd","aqs":"chrome..69i57j0l7.642j0j15","sourceid":"chrome","ie":"UTF-8"}"