Zamiast tego użyj interfejsu API URL Whatwg

const myURL ="Your URl";
const myURLObj = new URL(myURL);
Zealous Zebra