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

Host is empty #62

Closed
ikrivosheev opened this issue Feb 24, 2016 · 3 comments
Closed

Host is empty #62

ikrivosheev opened this issue Feb 24, 2016 · 3 comments

Comments

@ikrivosheev
Copy link

I have a simple url: new.rambler.ru

obj = furl("new.rambler.ru")
print obj.host, obj.scheme, obj.path
None None news.rambler.ru

I excepted that host is new.rambler.ru, scheme is None. But new.rambler.ru is in the path.
Is this a bug or expected behavior?

@gruns
Copy link
Owner

gruns commented Feb 24, 2016

Yep, this is expected behavior: new.rambler.ru is a perfectly valid path, too,
e.g. http://google.com/new.rambler.ru. It's ambiguous.

furl defaults to adopt that string as the path. This is the default behavior of
Python's urlparse(), too.

>>> from urlparse import urlparse
>>> urlparse('new.rambler.ru')
ParseResult(scheme='', netloc='', path='new.rambler.ru', params='', query='', fragment='')

To instruct furl to adopt new.rambler.ru as the host, not the path, you can
explicitly set the host

>>> from furl import furl
>>> f = furl().set(host='new.rambler.ru')
>>> f.host
'new.rambler.ru'

or provide a scheme so furl knows that new.rambler.ru is a host, not a path.

>>> from furl import furl
>>> f = furl('http://new.rambler.ru')
>>> f.host
'new.rambler.ru'

Does that answer your question?

@ikrivosheev
Copy link
Author

Yes, thanks!

@gruns
Copy link
Owner

gruns commented Feb 25, 2016

Closing this issue.

Thank you for bringing this to my attention, Ivan. Don't hesitate to let me know
if there's anything else I can help with.

@gruns gruns closed this as completed Feb 25, 2016
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

2 participants