parse-domain
parse-domain copied to clipboard
Wrong top level domain detection based on the public suffix list
Issue summary
As you can see here the eu.org belongs to the private domain section, so parsing a domain like example.eu.org should return org as the top-level domain, not the eu.org (I've mistaken these two concepts as well and opened a similar issue for a php package.)
| Information | Description |
|---|---|
| Module version | 7.0.1 |
| Node version | 16.17.0 |
| OS Platform | Linux 5.19.0-76051900-generic |
Standalone code, or another way to reproduce the problem
import { parseDomain, ParseResultType } from "parse-domain";
const parseResult = parseDomain(
// This should be a string with basic latin letters only.
// More information below.
"example.eu.org"
);
// Check if the domain is listed in the public suffix list
if (parseResult.type === ParseResultType.Listed) {
const { subDomains, domain, topLevelDomains } = parseResult;
console.log(subDomains); // []
console.log(domain); // "example"
console.log(topLevelDomains); // ["eu", "org"]
} else {
// Read more about other parseResult types below...
}
Expected result
-
org
Actual result
-
eu.org