[.NET] Fix string.PathJoin to be consistent with core

This commit is contained in:
Zae
2025-04-11 23:21:29 +08:00
parent 7b9c5122fa
commit e8311840e4

View File

@@ -1315,7 +1315,9 @@ namespace Godot
/// <returns>The concatenated path with the given file name.</returns>
public static string PathJoin(this string instance, string file)
{
if (instance.Length > 0 && instance[instance.Length - 1] == '/')
if (instance.Length == 0)
return file;
if (instance[^1] == '/' || (file.Length > 0 && file[0] == '/'))
return instance + file;
return instance + "/" + file;
}