mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #22278: Fix urljoin problem with relative urls, a regression observed
after changes to issue22118 were submitted. Patch contributed by Demian Brecht and reviewed by Antoine Pitrou.
This commit is contained in:
parent
e6c27c9f6b
commit
a66e3885fb
3 changed files with 20 additions and 1 deletions
|
@ -443,6 +443,10 @@ def urljoin(base, url, allow_fragments=True):
|
|||
segments = path.split('/')
|
||||
else:
|
||||
segments = base_parts + path.split('/')
|
||||
# filter out elements that would cause redundant slashes on re-joining
|
||||
# the resolved_path
|
||||
segments = segments[0:1] + [
|
||||
s for s in segments[1:-1] if len(s) > 0] + segments[-1:]
|
||||
|
||||
resolved_path = []
|
||||
|
||||
|
@ -465,7 +469,7 @@ def urljoin(base, url, allow_fragments=True):
|
|||
resolved_path.append('')
|
||||
|
||||
return _coerce_result(urlunparse((scheme, netloc, '/'.join(
|
||||
resolved_path), params, query, fragment)))
|
||||
resolved_path) or '/', params, query, fragment)))
|
||||
|
||||
|
||||
def urldefrag(url):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue