peerigon / parse-domain

Splits a hostname into subdomains, domain and (effective) top-level domains.
MIT License
508 stars 71 forks source link

No subdomain detected for withgoogle.com #143

Closed sergiomejicanos closed 2 years ago

sergiomejicanos commented 2 years ago

Parsing the following domain:

> await ParseDomain.parseDomain("analytics.withgoogle.com");
{
  type: 'LISTED',
  hostname: 'analytics.withgoogle.com',
  labels: [ 'analytics', 'withgoogle', 'com' ],
  icann: {
    subDomains: [ 'analytics' ],
    domain: 'withgoogle',
    topLevelDomains: [ 'com' ]
  },
  subDomains: [],
  domain: 'analytics',
  topLevelDomains: [ 'withgoogle', 'com' ]
}

I would have expected the subdomain array to include "analytics" and for the domain and TLD to be different.

Here's an example where this works correctly:

> await ParseDomain.parseDomain("analytics.google.com");
{
  type: 'LISTED',
  hostname: 'analytics.google.com',
  labels: [ 'analytics', 'google', 'com' ],
  icann: {
    subDomains: [ 'analytics' ],
    domain: 'google',
    topLevelDomains: [ 'com' ]
  },
  subDomains: [ 'analytics' ],
  domain: 'google',
  topLevelDomains: [ 'com' ]
}
jhnns commented 2 years ago

withgoogle.com is listed as public suffix and therefore treated as a top-level domain.

It's explained in the README: https://github.com/peerigon/parse-domain#%EF%B8%8F-effective-tlds--tlds-acknowledged-by-icann

funnylookinhat commented 2 years ago

@jhnns Aha! Thank you for explaining that and the link - that makes total sense. :+1: