Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,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 @@ -281,6 +280,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 @@ -449,6 +449,9 @@ def test_urljoins(self):
# issue 23703: don't duplicate filename
self.checkJoin('a', 'b', 'b')

# issue 39799: no base fragment (not compatible with RFC1808)
self.checkJoin('http://a/b#f', '', 'http://a/b')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this test to be under test_RFC3986?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for self.checkJoin('http://a/b/#f', 'g', 'http://a/b/g')?


def test_RFC2732(self):
str_cases = [
('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
Expand Down
2 changes: 0 additions & 2 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,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, bparams, bquery, bfragment = \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix ``urllib.parse.urljoin``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mention that this is in order to conform with RFC 3986?

when ``base`` has fragment and ``url`` is blank
(Returns ``base`` without fragment, not ``base`` entirely).