Skip to content

Determines the root domain for any domain, taking second level domains into account.

Notifications You must be signed in to change notification settings

Sandyman/root-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

root-domain

This module determines the root domain for any domain or sub domain. It takes into account that certain 'second level domains' exist, like '.co.uk' or 'com.au'.

Usage

Install

npm i root-domain -S

Use

const rootDomain = require('root-domain');

console.log(rootDomain('example.com'));                 // prints example.com
console.log(rootDomain('a.b.c.sub.example.com.au'));    // print example.com.au

The domain name MUST NOT end with a '/'.

Warning

Use this module at your own risk.

About

Determines the root domain for any domain, taking second level domains into account.

Resources

Stars

Watchers

Forks

Packages

No packages published