Skip to content

Commit

Permalink
Fix for 1.33: urlsplit() should only add '//' if scheme != ''.
Browse files Browse the repository at this point in the history
Will add test and backport.
  • Loading branch information
gvanrossum committed Oct 14, 2002
1 parent 6e75364 commit bbc0568
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def test_frags(self):
self.assertEqual(result2, url)

def checkJoin(self, base, relurl, expected):
self.assertEqual(urlparse.urljoin(base, relurl), expected)
self.assertEqual(urlparse.urljoin(base, relurl), expected,
(base, relurl, expected))

def test_unparse_parse(self):
for u in ['Python', './Python']:
self.assertEqual(urlparse.urlunparse(urlparse.urlparse(u)), u)

def test_RFC1808(self):
# "normal" cases from RFC 1808:
Expand Down
2 changes: 1 addition & 1 deletion Lib/urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def urlunparse((scheme, netloc, url, params, query, fragment)):
return urlunsplit((scheme, netloc, url, query, fragment))

def urlunsplit((scheme, netloc, url, query, fragment)):
if netloc or (scheme in uses_netloc and url[:2] != '//'):
if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
if url and url[:1] != '/': url = '/' + url
url = '//' + (netloc or '') + url
if scheme:
Expand Down

0 comments on commit bbc0568

Please sign in to comment.