Skip to content

Commit

Permalink
refs #166, ".." does not have extension ."
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed May 17, 2023
1 parent 8a2edd6 commit e5ae1bd
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -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);
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand Down

0 comments on commit e5ae1bd

Please sign in to comment.