Added sperate option "IUrlHelper and support for RouteOptions.LowercaseUrls "
@rynowak #518 #Issue: https://github.com/aspnet/Mvc/issues/7720
This commit is contained in:
parent
695fb00308
commit
f227cbeca3
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
|
|
||||||
var url = pathData.VirtualPath;
|
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 indexOfSeparator = url.IndexOfAny(UrlQueryDelimiters);
|
||||||
var urlWithoutQueryString = url;
|
var urlWithoutQueryString = url;
|
||||||
|
|
@ -154,11 +154,11 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
if (_options.LowercaseUrls)
|
if (_options.LowercaseUrls)
|
||||||
{
|
{
|
||||||
urlWithoutQueryString = urlWithoutQueryString.ToLowerInvariant();
|
urlWithoutQueryString = urlWithoutQueryString.ToLowerInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(queryString))
|
if (_options.LowercaseQueryStrings)
|
||||||
{
|
{
|
||||||
queryString = queryString.ToLowerInvariant();
|
queryString = queryString.ToLowerInvariant();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_options.AppendTrailingSlash && !urlWithoutQueryString.EndsWith("/"))
|
if (_options.AppendTrailingSlash && !urlWithoutQueryString.EndsWith("/"))
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,15 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
public class RouteOptions
|
public class RouteOptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public bool LowercaseUrls { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether a trailing slash should be appended to the generated URLs.
|
/// Gets or sets a value indicating whether a trailing slash should be appended to the generated URLs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue