Skip to content

Commit ff16c46

Browse files
committed
fix: always add double slash if scheme is in uses_netloc
1 parent 3e4498d commit ff16c46

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Lib/test/test_urlparse.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def test_roundtrips(self):
157157
('file:///tmp/junk.txt',
158158
('file', '', '/tmp/junk.txt', '', '', ''),
159159
('file', '', '/tmp/junk.txt', '', '')),
160+
('file:////tmp/junk.txt',
161+
('file', '', '//tmp/junk.txt', '', '', ''),
162+
('file', '', '//tmp/junk.txt', '', '')),
163+
('file://///tmp/junk.txt',
164+
('file', '', '///tmp/junk.txt', '', '', ''),
165+
('file', '', '///tmp/junk.txt', '', '')),
160166
('imap://mail.python.org/mbox1',
161167
('imap', 'mail.python.org', '/mbox1', '', '', ''),
162168
('imap', 'mail.python.org', '/mbox1', '', '')),

Lib/urllib/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def urlunsplit(components):
490490
empty query; the RFC states that these are equivalent)."""
491491
scheme, netloc, url, query, fragment, _coerce_result = (
492492
_coerce_args(*components))
493-
if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
493+
if netloc or (scheme and scheme in uses_netloc):
494494
if url and url[:1] != '/': url = '/' + url
495495
url = '//' + (netloc or '') + url
496496
if scheme:

0 commit comments

Comments
 (0)