Skip to content

Instantly share code, notes, and snippets.

@bradyclifford
Created August 4, 2021 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradyclifford/02717b46a5445340a8a1db12bea8578b to your computer and use it in GitHub Desktop.
Save bradyclifford/02717b46a5445340a8a1db12bea8578b to your computer and use it in GitHub Desktop.
Javascript Utils
const getDomainWithoutSubdomain = hostname => {
const parts = hostname.split('.')
return parts
.slice(0)
.slice(-(parts.length === 4 ? 3 : 2))
.join('.')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment