https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string
const getHostname = (url) => { // use URL constructor and return hostname return new URL(url).hostname; } let hostname = getHostname("https://google.com"); console.log(hostname); //google.com