Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
Added sperate option "IUrlHelper and support for RouteOptions.Lowerca…
Browse files Browse the repository at this point in the history
…seUrls "

@rynowak
#518
#Issue:  aspnet/Mvc#7720
  • Loading branch information
kishan.anem authored and rynowak committed Jun 1, 2018
1 parent 695fb00 commit f227cbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Microsoft.AspNetCore.Routing/RouteCollection.cs
Expand Up @@ -139,7 +139,7 @@ private VirtualPathData NormalizeVirtualPath(VirtualPathData pathData)

var url = pathData.VirtualPath;

if (!string.IsNullOrEmpty(url) && (_options.LowercaseUrls || _options.AppendTrailingSlash))
if (!string.IsNullOrEmpty(url) && (_options.LowercaseUrls || _options.LowercaseQueryStrings || _options.AppendTrailingSlash))
{
var indexOfSeparator = url.IndexOfAny(UrlQueryDelimiters);
var urlWithoutQueryString = url;
Expand All @@ -154,11 +154,11 @@ private VirtualPathData NormalizeVirtualPath(VirtualPathData pathData)
if (_options.LowercaseUrls)
{
urlWithoutQueryString = urlWithoutQueryString.ToLowerInvariant();
}

if (!string.IsNullOrEmpty(queryString))
{
queryString = queryString.ToLowerInvariant();
}
if (_options.LowercaseQueryStrings)
{
queryString = queryString.ToLowerInvariant();
}

if (_options.AppendTrailingSlash && !urlWithoutQueryString.EndsWith("/"))
Expand Down
7 changes: 6 additions & 1 deletion src/Microsoft.AspNetCore.Routing/RouteOptions.cs
Expand Up @@ -10,10 +10,15 @@ namespace Microsoft.AspNetCore.Routing
public class RouteOptions
{
/// <summary>
/// Gets or sets a value indicating whether all generated URLs are lower-case.
/// Gets or sets a value indicating whether all generated URLs are lower-case. it doesn't include the query string.
/// </summary>
public bool LowercaseUrls { get; set; }

/// <summary>
/// Gets or sets a value indicating whether all generated QUERY STRINGS are lower-case.
/// </summary>
public bool LowercaseQueryStrings { get; set; }

/// <summary>
/// Gets or sets a value indicating whether a trailing slash should be appended to the generated URLs.
/// </summary>
Expand Down

0 comments on commit f227cbe

Please sign in to comment.