To get the current url use the following code.
let url = new URL(window.location.href); console.log(url.href);