Skip to content

Instantly share code, notes, and snippets.

@RavenHursT
Created February 23, 2015 22:58
Show Gist options
  • Save RavenHursT/fe8a95a59109096ac1f8 to your computer and use it in GitHub Desktop.
Save RavenHursT/fe8a95a59109096ac1f8 to your computer and use it in GitHub Desktop.
Javascript extract root domain from URL
var extractRootDomain = function(url){
return url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i)[1].split('.').slice(-2).join('.');
};
@pesseyjulien
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment