fix io::path.parent() & update tests

This commit is contained in:
MihailRis
2025-02-04 12:53:05 +03:00
parent a653b063e6
commit e4c33e539e
3 changed files with 12 additions and 8 deletions
+2 -6
View File
@@ -110,13 +110,9 @@ namespace io {
path parent() const {
size_t slashpos = str.rfind('/');
if (slashpos == std::string::npos) {
return colonPos == std::string::npos
? path()
: path(str.substr(0, colonPos));
return colonPos == std::string::npos ? "" : str;
}
return colonPos == std::string::npos
? path(str.substr(0, slashpos))
: path(str.substr(0, colonPos) + str.substr(slashpos));
return str.substr(0, slashpos);
}
std::string string() const {