summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-08-14 16:55:14 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-08-14 16:55:14 (GMT)
commit23e3856b1e275aaff210723d4bbafbdd61cd8e75 (patch)
treeb1580a6b163d8cb55b9e215c137db146069ad04a /Lib/urllib
parent7b9cb2579c7edf49e4042bfb678ae2dc646d78ef (diff)
downloadcpython-23e3856b1e275aaff210723d4bbafbdd61cd8e75.zip
cpython-23e3856b1e275aaff210723d4bbafbdd61cd8e75.tar.gz
cpython-23e3856b1e275aaff210723d4bbafbdd61cd8e75.tar.bz2
Issue 1432. Fixes a bug caused because of the evolution
of the RFC that describes the behaviour. Note that we now have the same behaviour than the current browsers.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/parse.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index fe02db5..3e00695 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -219,9 +219,18 @@ def urljoin(base, url, allow_fragments=True):
if path[:1] == '/':
return urlunparse((scheme, netloc, path,
params, query, fragment))
- if not (path or params or query):
- return urlunparse((scheme, netloc, bpath,
- bparams, bquery, fragment))
+ if not path:
+ path = bpath
+ if not params:
+ params = bparams
+ else:
+ path = path[:-1]
+ return urlunparse((scheme, netloc, path,
+ params, query, fragment))
+ if not query:
+ query = bquery
+ return urlunparse((scheme, netloc, path,
+ params, query, fragment))
segments = bpath.split('/')[:-1] + path.split('/')
# XXX The stuff below is bogus in various ways...
if segments[-1] == '.':