if (typeof URLSearchParams !== 'undefined') {
const params = new URLSearchParams('param1=1¶m2=2¶m3=3')
console.log(params.toString())
params.delete('param2')
console.log(params.toString())
} else {
console.log(`Your browser ${navigator.appVersion} does not support URLSearchParams`)
}
var u = new URL('https://server.de/test?q#h')
u.hash = ''
u.search = ''
console.log(u.toString())
Run code snippetHide results
function getPathFromUrl(url) {
return url.split("?")[0];
}