diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-08-21 07:17:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 07:17:38 (GMT) |
commit | 90c892efeaae28bd849a01b42842f19dcd67b9f4 (patch) | |
tree | 802dcac935e91660ec901de7e2dca8692ba5bc51 /Lib/urllib | |
parent | 9dbd12375561a393eaec4b21ee4ac568a407cdb0 (diff) | |
download | cpython-90c892efeaae28bd849a01b42842f19dcd67b9f4.zip cpython-90c892efeaae28bd849a01b42842f19dcd67b9f4.tar.gz cpython-90c892efeaae28bd849a01b42842f19dcd67b9f4.tar.bz2 |
gh-85110: Preserve relative path in URL without netloc in urllib.parse.urlunsplit() (GH-123179)
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/parse.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 8f724f9..3316530 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -525,9 +525,13 @@ def urlunsplit(components): empty query; the RFC states that these are equivalent).""" scheme, netloc, url, query, fragment, _coerce_result = ( _coerce_args(*components)) - if netloc or (scheme and scheme in uses_netloc) or url[:2] == '//': + if netloc: if url and url[:1] != '/': url = '/' + url - url = '//' + (netloc or '') + url + url = '//' + netloc + url + elif url[:2] == '//': + url = '//' + url + elif scheme and scheme in uses_netloc and (not url or url[:1] == '/'): + url = '//' + url if scheme: url = scheme + ':' + url if query: |