Skip to content
Open
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
5 changes: 3 additions & 2 deletions upath/implementations/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ def resolve(
parts = list(self.parts)
if parts[-1:] == ["."]:
parts[-1:] = [""]
if parts[-2:] == ["", ".."]:
parts[-2:] = [""]
if parts[-1:] == [".."]:
# a final ".." names a directory: "/a/b/.." -> "/a/"
parts.append("")
pth = self.with_segments(*parts)
resolved_path = super(HTTPPath, pth).resolve(strict=strict)

Expand Down
2 changes: 2 additions & 0 deletions upath/tests/implementations/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def test_joinuri_behavior(base, rel, expected):
("http://example.com/a/..//.", "http://example.com//"),
("http://example.com/a/..//..", "http://example.com/"),
("http://example.com/a/../b", "http://example.com/b"),
("http://example.com/a/b/..", "http://example.com/a/"),
("http://example.com/a/b/../c/..", "http://example.com/a/"),
("http://example.com/a/..//b", "http://example.com//b"),
("http://example.com/a//..", "http://example.com/a/"),
("http://example.com/a//../", "http://example.com/a/"),
Expand Down
4 changes: 0 additions & 4 deletions upath/tests/test_special_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@
" on root_marker='' filesystems (github, webdav, hf, tar)"
),
"hdfs-trailing-slash": "candidate bug: hdfs keeps trailing slashes",
"http-final-dotdot": (
"candidate bug: a final '..' drops the trailing slash on http(s) paths"
),
}


Expand Down Expand Up @@ -418,7 +415,6 @@ def test_empty_parts_are_supported(protocol):
assert p.parts == (root.anchor, "a", "", "b")


@_xfail("http-final-dotdot")
def test_http_resolve_final_dotdot_is_a_directory():
# RFC 3986, section 5.2.4: "/a/b/.." normalizes to "/a/"
p = UPath("https://example.com/a/b/..")
Expand Down