mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
gh-85110: Preserve relative path in URL without netloc in urllib.parse.urlunsplit() (GH-123179)
This commit is contained in:
parent
9dbd123755
commit
90c892efea
3 changed files with 38 additions and 9 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue