Skip to content

Commit f227cbe

Browse files
kishan.anemrynowak
kishan.anem
authored andcommitted
Added sperate option "IUrlHelper and support for RouteOptions.LowercaseUrls "
@rynowak #518 #Issue: aspnet/Mvc#7720
1 parent 695fb00 commit f227cbe

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Microsoft.AspNetCore.Routing/RouteCollection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private VirtualPathData NormalizeVirtualPath(VirtualPathData pathData)
139139

140140
var url = pathData.VirtualPath;
141141

142-
if (!string.IsNullOrEmpty(url) && (_options.LowercaseUrls || _options.AppendTrailingSlash))
142+
if (!string.IsNullOrEmpty(url) && (_options.LowercaseUrls || _options.LowercaseQueryStrings || _options.AppendTrailingSlash))
143143
{
144144
var indexOfSeparator = url.IndexOfAny(UrlQueryDelimiters);
145145
var urlWithoutQueryString = url;
@@ -154,11 +154,11 @@ private VirtualPathData NormalizeVirtualPath(VirtualPathData pathData)
154154
if (_options.LowercaseUrls)
155155
{
156156
urlWithoutQueryString = urlWithoutQueryString.ToLowerInvariant();
157+
}
157158

158-
if (!string.IsNullOrEmpty(queryString))
159-
{
160-
queryString = queryString.ToLowerInvariant();
161-
}
159+
if (_options.LowercaseQueryStrings)
160+
{
161+
queryString = queryString.ToLowerInvariant();
162162
}
163163

164164
if (_options.AppendTrailingSlash && !urlWithoutQueryString.EndsWith("/"))

src/Microsoft.AspNetCore.Routing/RouteOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ namespace Microsoft.AspNetCore.Routing
1010
public class RouteOptions
1111
{
1212
/// <summary>
13-
/// Gets or sets a value indicating whether all generated URLs are lower-case.
13+
/// Gets or sets a value indicating whether all generated URLs are lower-case. it doesn't include the query string.
1414
/// </summary>
1515
public bool LowercaseUrls { get; set; }
1616

17+
/// <summary>
18+
/// Gets or sets a value indicating whether all generated QUERY STRINGS are lower-case.
19+
/// </summary>
20+
public bool LowercaseQueryStrings { get; set; }
21+
1722
/// <summary>
1823
/// Gets or sets a value indicating whether a trailing slash should be appended to the generated URLs.
1924
/// </summary>

0 commit comments

Comments
 (0)