lupomontero / psl

JavaScript domain name parser based on the Public Suffix List
https://www.npmjs.org/package/psl
MIT License
386 stars 79 forks source link

Private suffixes/TLDs? #41

Open stevenvachon opened 5 years ago

stevenvachon commented 5 years ago

While com is public, pepsi is private and not mentioned in the public list.

OlliV commented 5 years ago

What do you think should be the correct behavior? Currently it seems that's parsed correctly as a TLD:

> psl.parse('mycooldomain.pepsi')
{ input: 'mycooldomain.pepsi',
  tld: 'pepsi',
  sld: 'mycooldomain',
  domain: 'mycooldomain.pepsi',
  subdomain: null,
  listed: false }

Note that it returns listed: false.

I have a tangential question, what if the TLD is clearly invalid (at least to me):

> psl.parse('mycooldomain.com--invalid')
{ input: 'mycooldomain.com--invalid',
  tld: 'com--invalid',
  sld: 'mycooldomain',
  domain: 'mycooldomain.com--invalid',
  subdomain: null,
  listed: false }

This returns listed: false too but I'm not sure if this result is meaningful to me as a user.

Compare to this:

> psl.parse('....mycooldomain.com')
{ input: '....mycooldomain.com',
  error:
   { message: 'Domain name label should be at least 1 character long.',
     code: 'LABEL_TOO_SHORT' } }

or even better:

> psl.parse('--mycooldomain.com')
{ input: '--mycooldomain.com',
  error:
   { message: 'Domain name label can not start with a dash.',
     code: 'LABEL_STARTS_WITH_DASH' } }

Now as the left side is clearly invalid the domain is no longer accepted.

There is an expired draft for allowing xn-- in TLD names but I couldn't find if anything similar was ever accepted. draft-liman-tld-names-01. For example RFC 1123 refers that a TLD will be alphabetic, again I couldn't find any supporting evidence that it is clearly standardized to be so.

Therefore I'm not sure if - should be allowed but it looks suspicious to me.