Skip to content

Instantly share code, notes, and snippets.

@tleen
Created August 2, 2013 01:01
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 tleen/6136736 to your computer and use it in GitHub Desktop.
Save tleen/6136736 to your computer and use it in GitHub Desktop.
Extract main portion of hostname from url in node javascript without regex
url.parse('http://some.long.hostname.here.com/andpages.html').hostname.split('.').reverse().slice(0,2).reverse().join('.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment