Skip to content

Instantly share code, notes, and snippets.

@titivermeesch
Created April 23, 2020 17:55
Show Gist options
  • Save titivermeesch/4ed21188c2791cadeb6ad1e1a10c0138 to your computer and use it in GitHub Desktop.
Save titivermeesch/4ed21188c2791cadeb6ad1e1a10c0138 to your computer and use it in GitHub Desktop.
Extract domain name from an url
function domainName(url){
const parts = url.split('.').filter(el => !el.includes('www'))[0].split('://')
return parts[1] || parts[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment