Inconsistent TLD handling
Opened this issue · 0 comments
gavincarr commented
Hi Nick,
I think the current (0.19) TLD handling is a bit inconsistent / confusing.
Demo script:
use v5.10;
use Domain::PublicSuffix;
my $dps = Domain::PublicSuffix->new;
say "root: ", $dps->get_root_domain($ARGV[0]);
say "suffix: ", $dps->suffix;
say "tld: ", $dps->tld;
say "error: ", $dps->error;
For a 2LD like "com.au", I get:
./dps com.au
root:
suffix: com.au
tld: au
error: Domain is already a suffix
which seems good, but for a TLD, I just get:
./dps com
root:
suffix:
tld:
error: Malformed domain
which seems wrong ("com" is a valid domain, and a suffix/tld, just not a root domain), and inconsistent e.g. compared with "foo.com":
./dps foo.com
root: foo.com
suffix: com
tld: com
error:
Also, we get the same error for unlisted TLDs, which doesn't seem as helpful as the "Invalid TLD" error we get otherwise:
./dps cromulent
root:
suffix:
tld:
error: Malformed domain
vs.
./dps foo.cromulent
root:
suffix:
tld:
error: Invalid TLD
Do you think we could do away with the "Malformed domain" error for TLDs?
Thanks,
Gavin