Skip to content
Merged
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
3 changes: 2 additions & 1 deletion boltons/urlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ def navigate(self, dest):
if dest.path.startswith(u'/'): # absolute path
new_path_parts = list(dest.path_parts)
else: # relative path
new_path_parts = self.path_parts[:-1] + dest.path_parts
new_path_parts = list(self.path_parts[:-1]) \
+ list(dest.path_parts)
else:
new_path_parts = list(self.path_parts)
if not query_params:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_urlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,25 @@ def test_navigate():
assert navd.to_text() == _dest_text


@pytest.mark.parametrize(
('expected', 'base', 'paths'), [
('https://host/b', 'https://host', ('a', '/b', )),
('https://host/b', 'https://host', ('a', 'b', )),
('https://host/a/b', 'https://host', ('a/', 'b', )),
('https://host/b', 'https://host', ('/a', 'b', )),
('https://host/a/b', 'https://host/a/', (None, 'b', )),
('https://host/b', 'https://host/a', (None, 'b', )),
])
def test_chained_navigate(expected, base, paths):
"""Chained :meth:`navigate` calls produces correct results."""
url = URL(base)

for path in paths:
url = url.navigate(path)

assert expected == url.to_text()


# TODO: RFC3986 6.2.3 (not just for query add, either)
# def test_add_query():
# url = URL('http://www.example.com')
Expand Down