Fix for 1.33: urlsplit() should only add '//' if scheme != ''.

Will add test and backport.
This commit is contained in:
Guido van Rossum 2002-10-14 19:59:54 +00:00
parent 6e75364cbe
commit bbc0568a5c
2 changed files with 7 additions and 2 deletions

View File

@ -27,7 +27,12 @@ class UrlParseTestCase(unittest.TestCase):
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:

View File

@ -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: