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

Incorrect empty FQDN when no subdomain and domain #178

Closed
BookGin opened this issue Oct 27, 2019 · 1 comment · Fixed by #300
Closed

Incorrect empty FQDN when no subdomain and domain #178

BookGin opened this issue Oct 27, 2019 · 1 comment · Fixed by #300
Labels
low priority: caller can pre/post-process lenient by design, it is up to you to clean your inputs (see README)

Comments

@BookGin
Copy link

BookGin commented Oct 27, 2019

When the extract result's subdomain and domain are both empty, it will return an incorrect empty FQDN.

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tldextract
>>> tldextract.__version__
'2.2.0'
>>> tldextract.extract('http://s3.amazonaws.com/')
ExtractResult(subdomain='', domain='', suffix='s3.amazonaws.com')
>>> tldextract.extract('http://s3.amazonaws.com/').fqdn
''
>>> tldextract.extract('http://blogspot.com/')
ExtractResult(subdomain='', domain='', suffix='blogspot.com')
>>> tldextract.extract('http://blogspot.com/').fqdn
''

#174 would be a related issue but it's not the same.

Is this check really necessary?

if self.domain and self.suffix:
# self is the namedtuple (subdomain domain suffix)
return '.'.join(i for i in self if i)
return ''

@john-kurkowski
Copy link
Owner

Ugh, that is unintuitive. Private domains strike again. The check was originally for e.g. tldextract.extract('localhost'), where there is no FQDN to reconstruct. It didn't consider private domains.

Like this comment in #138, if we add a way for each suffix to know whether it is private or not, we could change the check to something like this.

if self.suffix and (self.domain or self.is_private):

@floer32 floer32 added the low priority: caller can pre/post-process lenient by design, it is up to you to clean your inputs (see README) label Mar 23, 2020
john-kurkowski added a commit that referenced this issue Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority: caller can pre/post-process lenient by design, it is up to you to clean your inputs (see README)
Projects
None yet
3 participants