diff --git a/src/EmbedIO/Routing/RouteMatcher.cs b/src/EmbedIO/Routing/RouteMatcher.cs index 28ceb7bb6..d6fec6634 100644 --- a/src/EmbedIO/Routing/RouteMatcher.cs +++ b/src/EmbedIO/Routing/RouteMatcher.cs @@ -13,7 +13,7 @@ namespace EmbedIO.Routing public sealed class RouteMatcher { private static readonly object SyncRoot = new object(); - private static readonly Dictionary Cache = new Dictionary(StringComparer.Ordinal); + private static readonly Dictionary<(bool, string), RouteMatcher> Cache = new Dictionary<(bool, string), RouteMatcher>(); private readonly Regex _regex; @@ -144,11 +144,11 @@ private static Exception TryParseInternal(string route, bool isBaseRoute, out Ro } route = UrlPath.UnsafeNormalize(route, isBaseRoute); - if (Cache.TryGetValue(route, out result)) + if (Cache.TryGetValue((isBaseRoute, route), out result)) return null; result = new RouteMatcher(isBaseRoute, route, pattern, parameterNames); - Cache.Add(route, result); + Cache.Add((isBaseRoute, route), result); return null; } }