Skip to content

Commit

Permalink
[FIX] RouteMatcher cache does not distinguish between base and non-ba…
Browse files Browse the repository at this point in the history
…se routes. (#347) (#348)
  • Loading branch information
rdeago authored and geoperez committed Aug 23, 2019
1 parent b2bb7c2 commit 1c54145
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/EmbedIO/Routing/RouteMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace EmbedIO.Routing
public sealed class RouteMatcher
{
private static readonly object SyncRoot = new object();
private static readonly Dictionary<string, RouteMatcher> Cache = new Dictionary<string, RouteMatcher>(StringComparer.Ordinal);
private static readonly Dictionary<(bool, string), RouteMatcher> Cache = new Dictionary<(bool, string), RouteMatcher>();

private readonly Regex _regex;

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 1c54145

Please sign in to comment.