Merge 371f9ad1f8d168497c37039d2ae7916bd55b37c1 into 9fda7b0afbd0640f482f4aea8720a8c0afd18740

This commit is contained in:
MikeG 2025-01-23 07:28:13 +01:00 committed by GitHub
commit a9260d3f10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -3261,11 +3261,12 @@ GHC_INLINE path path::lexically_normal() const
continue;
}
else if (s == ".." && !dest.empty()) {
auto root = root_path();
if (dest == root) {
if (dest == root_path()) {
continue;
}
else if (*(--dest.end()) != "..") {
const auto filename = *(--dest.end());
if (filename != ".." && !(filename.empty() && dest.has_parent_path() && dest.parent_path() == "..")) {
if (dest._path.back() == preferred_separator) {
dest._path.pop_back();
}

View File

@ -955,6 +955,7 @@ TEST_CASE("fs.path.gen - path generation", "[filesystem][path][fs.path.gen]")
CHECK(fs::path("ab/cd/ef/../../qw").lexically_normal() == "ab/qw");
CHECK(fs::path("a/b/../../../c").lexically_normal() == "../c");
CHECK(fs::path("../").lexically_normal() == "..");
CHECK(fs::path("../foo/../../bar/").lexically_normal() == "../../bar/");
#ifdef GHC_OS_WINDOWS
CHECK(fs::path("\\/\\///\\/").lexically_normal() == "/");
CHECK(fs::path("a/b/..\\//..///\\/../c\\\\/").lexically_normal() == "../c/");