Add StringUtils tests and Paths test and fix detected problem with rooted path starting with ./

This commit is contained in:
Wojciech Figat
2022-08-19 11:54:09 +02:00
parent 01eb42dd10
commit a3a44f0cef
2 changed files with 65 additions and 2 deletions

View File

@@ -336,7 +336,7 @@ void StringUtils::PathRemoveRelativeParts(String& path)
Array<String> components;
path.Split(TEXT('/'), components);
Array<String> stack;
Array<String, InlinedAllocation<16>> stack;
for (auto& bit : components)
{
if (bit == TEXT(".."))
@@ -365,7 +365,7 @@ void StringUtils::PathRemoveRelativeParts(String& path)
}
}
const bool isRooted = path.StartsWith(TEXT('/'));
const bool isRooted = path.StartsWith(TEXT('/')) || (path.Length() >= 2 && path[0] == '.' && path[1] == '/');
path.Clear();
for (auto& e : stack)
path /= e;