Reputation: 18097
Given urls like these
www.yahoo.com
support.abc.com/whatever?a=1
clear.com
biz.co.uk/how
How do I get
yahoo.com
abc.com
clear.com
biz.co.uk
Url.parse.hostname returns url including subdomain and how would nodejs or browser know biz is domain name not subdomain
Upvotes: 1
Views: 1731
Reputation: 239910
and how would nodejs or browser know biz is domain name not subdomain
Using the Public Suffix List information, for example through a library like tldjs for JavaScript.
Upvotes: 2