code: function removeSubdomains(hostname) {
    const hostnameParts = hostname.split('.');
  
    // A hostname with less than three parts is as short as it will get.
    if (hostnameParts.length < 2) {
      return hostname;
    }
  
    // Try to find a match in the list of ccTLDs.
    const ccTld = find(tldList, part => endsWith(hostname, `.${part}`));
    if (ccTld) {
      // Get one extra part from the hostname.
      const partCount = ccTld.split('.').length + 1;
      return hostnameParts.slice(0 - partCount).join('.');
    }
  
    // If no ccTLDs were matched, return the final two parts of the hostname.
    return hostnameParts.slice(-2).join('.');
  }
docs: Remove subdomains while respecting a number of secondary ccTLDs.