Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDomain('blogspot.co.uk') returns null… what's a domain? #25

Open
thom4parisot opened this issue Jan 8, 2013 · 7 comments
Open
Labels

Comments

@thom4parisot
Copy link
Owner

Because PublicSuffix list contains rules, domains and "reserved domains", it's finally harsh again to detect what's a real domain from a TLD, an SLD or something else.

Back to zero?

@myndzi
Copy link
Collaborator

myndzi commented May 25, 2015

What's the difference between a domain and a "reserved domain"? Shouldn't it not matter and be treated just like any other public suffix? On the specification on publicsuffix.org, I see no mention of any distinction and, indeed, the rules themselves appear to make no distinction...

@thom4parisot
Copy link
Owner Author

@myndzi yep you are right.

The initial motivation to create this module was to be able to detect domain names with confidence, not only with a pattern but with TLD validation. I did not have in mind to check cookie domains or whatsoever; it just happened there was publicsuffixlist as an available tld provider, with some cool additional rules.

@ikari-pl
Copy link

This is also super confusing:

> tld.getDomain('google.com')
'google.com'

but

> tld.getDomain('s3.amazonaws.com')
null

Can I suggest mentioning in the docs? I don't think the README mentions this :( Thanks for the public suffix method.

@olivierbeaulieu
Copy link

Would you guys be open to making this feature configurable? I love TLDJS, but this "valid host" check is causing issues in my product, and unless I can disable it through a configuration, I'm gonna be forced to look for another library to use.

I'm gonna make a fork to fix the problem for myself, however I doubt that I'm the only one having issues with this. Thoughts?

@olivierbeaulieu
Copy link

Digging further I'm realizing that there is no distinction in rules.json between "domains" marking themselves as invalid and legit TLDs like .co.uk... Hmm I feel like this is going to be more complex than I thought.

@thom4parisot
Copy link
Owner Author

Well, as the implementation was based on complying to the publicsuffix.org list, I guess confusion happens on what we are trying to do.

import tld from 'tldjs'

tld.tldExists('google'); // true
tld.tldExists('maps.google'); // true
tld.tldExists('s3.amazonaws.com'); // true
tld.getDomain('s3.amazonaws.com'); // amazonaws.com
tld.getDomain('blogspot.co.uk'); // blogspot.co.uk
tld.getSubdomain('s3.amazonaws.com'); // s3
tld.getPublicSuffix('s3.amazonaws.com'); // s3.amazonaws.com

Some clarity has to be added to isValid:

  • if the hostname validity is checked, the localhost should be valid
  • but .localhost should not

Depending on how people use the library for, some convenient methods could be added.

@thom4parisot
Copy link
Owner Author

Undergoing conversation about making things clearer in #124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants