node package manager

tldextract

Extract domain, subdomain and tld from a url

tldextract

Accurately separates the gTLD or ccTLD (generic or country code top-level domain) from the registered domain and subdomains of a URL.

var tldextract = require('tldextract');
 
tldextract('http://forums.news.cnn.com/', function (errobj) {
  // obj: {subdomain: 'forums.news', domain: 'cnn', tld: 'com'} 
});
 
tldextract('http://ye.ye.ye.ye/', function (errobj) {
  // obj: {subdomain: 'ye', domain: 'ye', tld: 'ye.ye'} 
});
make

This module is a port of the python module tldextract.