Skip to content

Commit

Permalink
Merge pull request #57 from ligfx/fix_lexically_relative_to_path_with…
Browse files Browse the repository at this point in the history
…_trailing_slash

refs #56, lexically_relative: ignore trailing slash on base
  • Loading branch information
gulrak authored Mar 23, 2020
2 parents 26077f2 + e3201da commit 82d5d83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@ GHC_INLINE path path::lexically_relative(const path& base) const
}
int count = 0;
for (const auto& element : input_iterator_range<const_iterator>(b, base.end())) {
if (element != "." && element != "..") {
if (element != "." && element != "" && element != "..") {
++count;
}
else if (element == "..") {
Expand Down
1 change: 1 addition & 0 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ TEST_CASE("30.10.8.4.11 path generation", "[filesystem][path][fs.path.gen]")
CHECK(fs::path("a/b/c").lexically_relative("a/b/c/x/y") == "../..");
CHECK(fs::path("a/b/c").lexically_relative("a/b/c") == ".");
CHECK(fs::path("a/b").lexically_relative("c/d") == "../../a/b");
CHECK(fs::path("a/b").lexically_relative("a/") == "b");
if (has_host_root_name_support()) {
CHECK(fs::path("//host1/foo").lexically_relative("//host2.bar") == "");
}
Expand Down

0 comments on commit 82d5d83

Please sign in to comment.