var url = new URL("",location);
console.log(url.host); // ip address or hostname:port number
console.log(url.protocol); // protocol
console.log(url.hostname); // ip address or hostname
console.log(url.port); // port number
console.log(url.origin); // protocol://ip address or hostname:port number
console.log(url.pathname); // /current path/
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter