COMMON: Fix Path::baseName

When baseName was called with a base name path but escaped, unescape was
called with the escaping marker while this is not allowed.
This commit is contained in:
Le Philousophe 2024-05-19 21:18:34 +02:00
parent c30b68115a
commit b8e08ff2a0
2 changed files with 6 additions and 0 deletions

View File

@ -396,6 +396,9 @@ String Path::baseName() const {
if (separatorPos != String::npos) {
begin += separatorPos + 1;
} else if (isEscaped()) {
// unescape uses the real start, not the escape marker
begin++;
}
end += last;

View File

@ -89,6 +89,9 @@ class PathTestSuite : public CxxTest::TestSuite
Common::Path p4("parent/dir/file.txt/");
TS_ASSERT_EQUALS(p4.baseName(), "file.txt");
Common::Path p5("File I/O", ':');
TS_ASSERT_EQUALS(p5.baseName(), "File I/O");
}
void test_getParent() {