Use a API Whatwg URL em vez disso
const myURL ="Your URl";
const myURLObj = new URL(myURL);
Zealous Zebra
const myURL ="Your URl";
const myURLObj = new URL(myURL);