Skip to content

Instantly share code, notes, and snippets.

@callblueday
Created October 8, 2013 11:35
Show Gist options
  • Save callblueday/6883370 to your computer and use it in GitHub Desktop.
Save callblueday/6883370 to your computer and use it in GitHub Desktop.
/**
* Get domain name from url
* eg: 'http://123.blog.163.com/123/123.html'
*/
getDomainName = function(url_str) {
return url_str.match(/(\w+\.(?:com|cn|net|org|cc|so|be|me|io|edu|gov|info|tv|museum|coop|aero|
int|biz|name|pro|aero|travel|jobs|mobi|jp|hk))(?:\/|$)/)[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment