refs #166, ".." does not have extension ."

This commit is contained in:
Steffen Schuemann 2023-05-17 07:18:52 +02:00
parent 8a2edd6d92
commit e5ae1bd3e3
2 changed files with 5 additions and 1 deletions

View File

@ -3170,7 +3170,7 @@ GHC_INLINE path path::extension() const
auto iter = end();
const auto& fn = *--iter;
impl_string_type::size_type pos = fn._path.rfind('.');
if (pos != std::string::npos && pos > 0) {
if (pos != std::string::npos && pos > 0 && fn._path != "..") {
return path(fn._path.substr(pos), native_format);
}
}

View File

@ -817,6 +817,8 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path.
#else
CHECK(fs::path("t:est.txt").stem() == "t:est");
#endif
CHECK(fs::path("/foo/.").stem() == ".");
CHECK(fs::path("/foo/..").stem() == "..");
// extension()
CHECK(fs::path("/foo/bar.txt").extension() == ".txt");
@ -825,6 +827,8 @@ TEST_CASE("fs.path.decompose - path decomposition", "[filesystem][path][fs.path.
CHECK(fs::path(".bar").extension() == "");
CHECK(fs::path("..bar").extension() == ".bar");
CHECK(fs::path("t:est.txt").extension() == ".txt");
CHECK(fs::path("/foo/.").extension() == "");
CHECK(fs::path("/foo/..").extension() == "");
if (has_host_root_name_support()) {
// //host-based root-names