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

Any way to isolate the subdomain? #106

Open
ejohb opened this issue Aug 28, 2018 · 3 comments
Open

Any way to isolate the subdomain? #106

ejohb opened this issue Aug 28, 2018 · 3 comments

Comments

@ejohb
Copy link

ejohb commented Aug 28, 2018

Hi,

  • http://www.example.com
  • http://test.subdomain.example.com

Is there a furl attribute for the subdomains in URLs - e.g. the ['www'] and ['test','subdomain'] above?

@gruns
Copy link
Owner

gruns commented Sep 12, 2018

Unfortunately there's currently no reliable way to isolate the subdomain because
it's non-trivial to determine the TLD (e.g. .com, .co.uk, etc). See

In the future, I'll add full TLD support to furl.

In the interim, splitting and rejoining the host by periods (.) is a
straightforward, intuitive way to isolate the subdomain assuming a simple, one
token TLD (e.g. .com, .net, etc).

>>> from furl import furl
>>> f = furl('http://test.subdomain.example.com/')
>>> tld = f.host.split('.')[-1]
>>> tld
'com'
>>> subdomain = '.'.join(f.host.split('.')[:-2])
>>> subdomain
'test.subdomain'

Does this suffice for your needs for now?

@bukowa
Copy link

bukowa commented Dec 3, 2018

https://github.com/john-kurkowski/tldextract

@gruns
Copy link
Owner

gruns commented Dec 17, 2018

Resolution of this Issue tied with the resolution of #110.

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

No branches or pull requests

3 participants