Получить URL без строки запроса
window.location.href.split('?')[0]
mohammad ghari
window.location.href.split('?')[0]
let path = window.location.href.split('?')[0]
console.log({path})
// {
// "path": "https://stacksnippets.net/js"
// }
//or
location.href.replace(location.search, '')