From e8311840e40bcad22c8e01198cdf3697c9bc9037 Mon Sep 17 00:00:00 2001 From: Zae Date: Fri, 11 Apr 2025 23:21:29 +0800 Subject: [PATCH] [.NET] Fix `string.PathJoin` to be consistent with core --- .../mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index d1a829fe82e..3fadfda0a3f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -1315,7 +1315,9 @@ namespace Godot /// The concatenated path with the given file name. 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; }