summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/parse.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2014-09-22 07:49:16 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2014-09-22 07:49:16 (GMT)
commita66e3885fb7bafbe69d738f500a63bd6718b0076 (patch)
tree08fa3d6c998549cd24da7694eb9df1d06cf21129 /Lib/urllib/parse.py
parente6c27c9f6b381f1970e8639d298e87446dbf1a61 (diff)
downloadcpython-a66e3885fb7bafbe69d738f500a63bd6718b0076.zip
cpython-a66e3885fb7bafbe69d738f500a63bd6718b0076.tar.gz
cpython-a66e3885fb7bafbe69d738f500a63bd6718b0076.tar.bz2
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.
Diffstat (limited to 'Lib/urllib/parse.py')
-rw-r--r--Lib/urllib/parse.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index b6ac414..8bbeab6 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -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):