UNPKG

374 BPlain TextView Raw
1// We want only the final segment of a domain, without any
2// preceding subdomains. However, we do keep leading `.` when
3// subdomains exist.
4export function getRootDomain(domain: string) {
5 const parts = domain.split('.');
6 const baseDomainOnly = parts.slice(-2).join('.');
7
8 return parts.length > 2 ? `.${baseDomainOnly}` : baseDomainOnly;
9}
10
11export function noop() {}