Open this example in the interactive library
Source code
const url = new URL("https://café.example/menu");
console.log(url.hostname, url.pathname);
Sample output
xn--caf-dma.example /menu

Open this example in the interactive library
const url = new URL("https://café.example/menu");
console.log(url.hostname, url.pathname);
xn--caf-dma.example /menu