How to use the tldts-experimental.getPublicSuffix function in tldts-experimental

To help you get started, we’ve selected a few tldts-experimental examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cliqz-oss / adblocker / bench / dataset / create_list.js View on Github external
function getHostnameWithoutSuffix(hostname) {
  const publicSuffix = getPublicSuffix(hostname);
  if (publicSuffix === null) {
    return hostname;
  }

  const hostnameWithoutSuffix = hostname.substr(0, hostname.length - publicSuffix.length - 1);

  if (hostnameWithoutSuffix.length === 0) {
    return hostname;
  }

  return hostnameWithoutSuffix;
}

tldts-experimental

Library to work against complex domain names, subdomains and URIs.

MIT
Latest version published 23 hours ago

Package Health Score

80 / 100
Full package analysis