Permalink
Browse files

Don't add a scheme to the input url of urlsplit(url) if one wasn't pr…

…ovided originally.
  • Loading branch information...
1 parent 7f7e2d6 commit 8e8664637791a353a89aa8dfab16d43ff065f184 Arthur Grunseid committed Apr 13, 2012
Showing with 13 additions and 0 deletions.
  1. +7 −0 furl/furl.py
  2. +6 −0 tests/test_furl.py
View
@@ -663,6 +663,8 @@ def load(self, url):
tokens = urlsplit(url) # Raises ValueError on malformed IPv6 address.
+ print 'tokens', tokens
+
self.netloc = tokens.netloc # Raises ValueError.
self.scheme = tokens.scheme.lower()
if not self.port:
@@ -1047,6 +1049,11 @@ def urlsplit(url):
http://docs.python.org/library/urlparse.html#urlparse.urlsplit
"""
+ # If a scheme wasn't provided, we shouldn't add one by setting the scheme to
+ # 'http'. We can use urlparse.urlsplit(url) as-is.
+ if '://' not in url:
+ return urlparse.urlsplit(url)
+
def _change_urltoks_scheme(tup, scheme):
l = list(tup)
l[0] = scheme
View
@@ -1287,6 +1287,12 @@ def test_join(self):
assert f is f.join(join) and f.url == result
def test_urlsplit(self):
+ # Without any delimeters like '://' or '/', the input should become a path.
+ urls = ['sup', '127.0.0.1', 'www.google.com', '192.168.1.1:8000']
+ for url in urls:
+ assert isinstance(furl.urlsplit(url), urlparse.SplitResult)
+ assert furl.urlsplit(url) == urlparse.urlsplit(url)
+
# No changes to existing urlsplit() behavior for known schemes.
url = 'http://www.pumps.com/'
assert isinstance(furl.urlsplit(url), urlparse.SplitResult)

0 comments on commit 8e86646

Please sign in to comment.