Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}