tld-extract
Install
npm i tld-extractUsage
const parser = require('tld-extract')const part = parser('http://www.google.com') // { tld: 'com', domain: 'google.com', sub: 'www' }NOTE: tld-extract library size is pretty big
URL
const url = 'http://www.google.com'const part = new URL(url){
hash: ""
host: "www.google.com"
hostname: "www.google.com"
href: "http://www.google.com/"
origin: "http://www.google.com"
password: ""
pathname: "/"
port: ""
protocol: "http:"
search: ""
searchParams: URLSearchParams {}
username: ""
}NOTE: Refer URL. host will include port if specified.