Fix: In furl/furl.py, the origin property (~line 1540) unconditionally... - #200
Open
M001N wants to merge 1 commit into
Open
Fix: In furl/furl.py, the origin property (~line 1540) unconditionally...#200M001N wants to merge 1 commit into
M001N wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added an early return in the origin property: if both scheme and host are empty, return '' instead of formatting the '://' template. The origin.setter and all other call sites (e.g. url composition using scheme+host+port directly, not origin) are unaffected; normal furls with scheme+host still produce the same origin string as before.
Problem
gruns/furl issue reference: #112
Root Cause
In furl/furl.py, the origin property (~line 1540) unconditionally formats '%s://%s%s' % (scheme, host, port) using self.scheme or '' and idna_encode(self.host) or ''. When a furl has neither scheme nor host (e.g. furl('www.google.com'), which furl parses as a schemeless, hostless path), both substitutions are empty strings, so the format always yields the literal '://' instead of a sensible empty/falsy value.
Testing
PASS - 70 passed, 3 deselected (test_netloc, test_hosts, test_odd_urls are pre-existing unrelated IPv6/path-edge-case failures on this environment, confirmed failing identically before this change; test_origin passes including new assertions for furl.furl().origin == '' and furl.furl('www.google.com').origin == ''.
Related Issue
#112