fix(router): ship audit bundle frontdoor cutover

This commit is contained in:
master
2026-03-08 14:30:12 +02:00
parent 8852928115
commit 30532800ec
9 changed files with 367 additions and 16 deletions

View File

@@ -45,6 +45,8 @@ public static class GatewayOptionsValidator
private static void ValidateRoutes(List<StellaOpsRoute> routes)
{
var exactPathIndices = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
for (var i = 0; i < routes.Count; i++)
{
var route = routes[i];
@@ -66,6 +68,17 @@ public static class GatewayOptionsValidator
throw new InvalidOperationException($"{prefix}: Path is not a valid regex pattern: {ex.Message}");
}
}
else
{
var normalizedPath = NormalizePath(route.Path);
if (exactPathIndices.TryGetValue(normalizedPath, out var existingIndex))
{
throw new InvalidOperationException(
$"{prefix}: Duplicate route path '{normalizedPath}' already defined by Route[{existingIndex}].");
}
exactPathIndices[normalizedPath] = i;
}
switch (route.Type)
{
@@ -124,4 +137,16 @@ public static class GatewayOptionsValidator
}
}
}
private static string NormalizePath(string value)
{
var normalized = value.Trim();
if (!normalized.StartsWith('/'))
{
normalized = "/" + normalized;
}
normalized = normalized.TrimEnd('/');
return string.IsNullOrEmpty(normalized) ? "/" : normalized;
}
}