fix: normalize away './' path prefixes

This commit is contained in:
CJ van den Berg 2025-10-23 23:24:58 +02:00
parent 5b23998376
commit e053a0dcf4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 53 additions and 10 deletions

View file

@ -0,0 +1,19 @@
const std = @import("std");
const pm = @import("project_manager");
test "normalize_file_path_dot_prefix" {
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix("example.txt"));
try std.testing.expectEqualStrings("/example.txt", pm.normalize_file_path_dot_prefix("/example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix("./example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix("././example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix(".//example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix(".//./example.txt"));
try std.testing.expectEqualStrings("example.txt", pm.normalize_file_path_dot_prefix(".//.//example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix("./../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix(".//../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix("././../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix("././/../example.txt"));
try std.testing.expectEqualStrings("../example.txt", pm.normalize_file_path_dot_prefix(".//.//../example.txt"));
try std.testing.expectEqualStrings("./", pm.normalize_file_path_dot_prefix("./"));
try std.testing.expectEqualStrings(".", pm.normalize_file_path_dot_prefix("."));
}