Fix handling of trailing slash

This commit is contained in:
vgeorgiev 2024-02-21 17:55:00 -06:00 committed by GitHub
parent 768b5cb11b
commit eeed314237
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -3306,7 +3306,7 @@ GHC_INLINE path path::lexically_relative(const path& base) const
--count;
}
}
if (count == 0 && (a == end() || empty())) {
if (count == 0 && (a == end() || a->empty())) {
return path(".");
}
if (count < 0) {

View File

@ -966,6 +966,7 @@ TEST_CASE("fs.path.gen - path generation", "[filesystem][path][fs.path.gen]")
CHECK(fs::path("/a/d").lexically_relative("/a/b/c") == "../../d");
CHECK(fs::path("/a/b/c").lexically_relative("/a/d") == "../b/c");
CHECK(fs::path("/a/b/c").lexically_relative("/a/b/c/d/..") == ".");
CHECK(fs::path("/a/b/c/").lexically_relative("/a/b/c/d/..") == ".");
CHECK(fs::path("").lexically_relative("/a/..") == "");
CHECK(fs::path("").lexically_relative("a/..") == ".");
CHECK(fs::path("a/b/c").lexically_relative("a") == "b/c");