diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index ce2ca0e..f926d38 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -2621,6 +2621,7 @@ GHC_INLINE bool path::is_relative() const GHC_INLINE path path::lexically_normal() const { path dest; + bool lastDotDot = false; for (const string_type& s : *this) { if (s == ".") { dest /= ""; @@ -2639,17 +2640,14 @@ GHC_INLINE path path::lexically_normal() const continue; } } - dest /= s; + if (!(s.empty() && lastDotDot)) { + dest /= s; + } + lastDotDot = s == ".."; } if (dest.empty()) { dest = "."; } - else { - static const path suffix[2] = {"", ".."}; - if(std::equal(std::reverse_iterator(dest.end()), std::reverse_iterator(dest.begin()), suffix)) { - dest._path.pop_back(); - } - } return dest; }