Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ def test_RFC1808(self):
self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g')

# "abnormal" cases from RFC 1808:
self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f')
self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.')
self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g')
self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..')
Expand All @@ -412,6 +411,7 @@ def test_RFC1808(self):
#self.checkJoin(RFC1808_BASE, 'http:', 'http:')

# XXX: The following tests are no longer compatible with RFC3986
# self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f')
# self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g')
# self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g')
# self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g')
Expand Down Expand Up @@ -525,6 +525,10 @@ def test_RFC3986(self):
# Test for issue9721
self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')

# Tests for issue39799: no base fragment
self.checkJoin('http://a/b#f', '', 'http://a/b')
self.checkJoin('http://a/b/#f', 'g', 'http://a/b/g')

def test_urljoins(self):
self.checkJoin(SIMPLE_BASE, 'g:h','g:h')
self.checkJoin(SIMPLE_BASE, 'g','http://a/b/c/g')
Expand Down
2 changes: 0 additions & 2 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,6 @@ def urljoin(base, url, allow_fragments=True):
interpretation of the latter."""
if not base:
return url
if not url:
return base

base, url, _coerce_result = _coerce_args(base, url)
bscheme, bnetloc, bpath, bquery, bfragment = \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``urllib.parse.urljoin``.
In RFC 3986, ``base``'s fragment is always discarded.
Loading