diff --git a/src/Microsoft.AspNetCore.Routing/RouteCollection.cs b/src/Microsoft.AspNetCore.Routing/RouteCollection.cs index d0be724b5b..a2dae64291 100644 --- a/src/Microsoft.AspNetCore.Routing/RouteCollection.cs +++ b/src/Microsoft.AspNetCore.Routing/RouteCollection.cs @@ -12,6 +12,7 @@ namespace Microsoft.AspNetCore.Routing { public class RouteCollection : IRouteCollection { + private readonly static char[] UrlQueryDelimiters = new char[] { '?', '#' }; private readonly List _routes = new List(); private readonly List _unnamedRoutes = new List(); private readonly Dictionary _namedRoutes = @@ -140,7 +141,7 @@ namespace Microsoft.AspNetCore.Routing if (!string.IsNullOrEmpty(url) && (_options.LowercaseUrls || _options.AppendTrailingSlash)) { - var indexOfSeparator = url.IndexOfAny(new char[] { '?', '#' }); + var indexOfSeparator = url.IndexOfAny(UrlQueryDelimiters); var urlWithoutQueryString = url; var queryString = string.Empty; @@ -177,4 +178,4 @@ namespace Microsoft.AspNetCore.Routing } } } -} \ No newline at end of file +}