I tried a lot to replace the query parameter using Javascript. But its not working. Can you please share any solutions to replace the parameter.
Below is the example:
console.log("www.test.com?x=a".replace(new RegExp(`${"x=a"}&?`),''));
The output I get is www.test.com ?. Is there any way to replace ? and to get only www.test.com?
new URL(url).hostnameshould work