Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions 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 @@ -577,7 +577,7 @@ def test_urljoins(self):
self.checkJoin('a', 'b', 'b')

# Test with empty (but defined) components.
self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f')
self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q')
self.checkJoin(RFC1808_BASE, '#', 'http://a/b/c/d;p?q#', relroundtrip=False)
self.checkJoin(RFC1808_BASE, '#z', 'http://a/b/c/d;p?q#z')
self.checkJoin(RFC1808_BASE, '?', 'http://a/b/c/d;p?', relroundtrip=False)
Expand All @@ -588,7 +588,7 @@ def test_urljoins(self):
self.checkJoin(RFC1808_BASE, ';#z', 'http://a/b/c/;#z')
self.checkJoin(RFC1808_BASE, ';x', 'http://a/b/c/;x')
self.checkJoin(RFC1808_BASE, '/w', 'http://a/w')
self.checkJoin(RFC1808_BASE, '//', 'http://a/b/c/d;p?q#f')
self.checkJoin(RFC1808_BASE, '//', 'http://a/b/c/d;p?q')
self.checkJoin(RFC1808_BASE, '//#z', 'http://a/b/c/d;p?q#z')
self.checkJoin(RFC1808_BASE, '//?y', 'http://a/b/c/d;p?y')
self.checkJoin(RFC1808_BASE, '//;x', 'http://;x')
Expand All @@ -597,7 +597,7 @@ def test_urljoins(self):
# For backward compatibility with RFC1630, the scheme name is allowed
# to be present in a relative reference if it is the same as the base
# URI scheme.
self.checkJoin(RFC1808_BASE, 'http:', 'http://a/b/c/d;p?q#f')
self.checkJoin(RFC1808_BASE, 'http:', 'http://a/b/c/d;p?q')
self.checkJoin(RFC1808_BASE, 'http:#', 'http://a/b/c/d;p?q#', relroundtrip=False)
self.checkJoin(RFC1808_BASE, 'http:#z', 'http://a/b/c/d;p?q#z')
self.checkJoin(RFC1808_BASE, 'http:?', 'http://a/b/c/d;p?', relroundtrip=False)
Expand All @@ -608,7 +608,7 @@ def test_urljoins(self):
self.checkJoin(RFC1808_BASE, 'http:;#z', 'http://a/b/c/;#z')
self.checkJoin(RFC1808_BASE, 'http:;x', 'http://a/b/c/;x')
self.checkJoin(RFC1808_BASE, 'http:/w', 'http://a/w')
self.checkJoin(RFC1808_BASE, 'http://', 'http://a/b/c/d;p?q#f')
self.checkJoin(RFC1808_BASE, 'http://', 'http://a/b/c/d;p?q')
self.checkJoin(RFC1808_BASE, 'http://#z', 'http://a/b/c/d;p?q#z')
self.checkJoin(RFC1808_BASE, 'http://?y', 'http://a/b/c/d;p?y')
self.checkJoin(RFC1808_BASE, 'http://;x', 'http://;x')
Expand Down
4 changes: 0 additions & 4 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 All @@ -589,8 +587,6 @@ def urljoin(base, url, allow_fragments=True):
path = bpath
if query is None:
query = bquery
if fragment is None:
fragment = bfragment
return _coerce_result(_urlunsplit(scheme, netloc, path,
query, fragment))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The fragment of the base URI is now always discarded in :func:`urllib.parse.urljoin` in accordance to :rfc:`3986`.
Loading