Changed string.Format to StringBuilder
This commit is contained in:
parent
308dd109a0
commit
663c7917d0
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Http.Extensions
|
namespace Microsoft.AspNet.Http.Extensions
|
||||||
{
|
{
|
||||||
|
|
@ -10,6 +11,8 @@ namespace Microsoft.AspNet.Http.Extensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class UriHelper
|
public static class UriHelper
|
||||||
{
|
{
|
||||||
|
private const string SchemeDelimiter = "://";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Combines the given URI components into a string that is properly encoded for use in HTTP headers.
|
/// Combines the given URI components into a string that is properly encoded for use in HTTP headers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -48,7 +51,15 @@ namespace Microsoft.AspNet.Http.Extensions
|
||||||
FragmentString fragment = new FragmentString())
|
FragmentString fragment = new FragmentString())
|
||||||
{
|
{
|
||||||
string combinePath = (pathBase.HasValue || path.HasValue) ? (pathBase + path).ToString() : "/";
|
string combinePath = (pathBase.HasValue || path.HasValue) ? (pathBase + path).ToString() : "/";
|
||||||
return $"{scheme}://{host.ToString()}{combinePath}{query.ToString()}{fragment.ToString()}";
|
|
||||||
|
return new StringBuilder()
|
||||||
|
.Append(scheme)
|
||||||
|
.Append(SchemeDelimiter)
|
||||||
|
.Append(host.ToString())
|
||||||
|
.Append(combinePath)
|
||||||
|
.Append(query.ToString())
|
||||||
|
.Append(fragment.ToString())
|
||||||
|
.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -93,7 +104,14 @@ namespace Microsoft.AspNet.Http.Extensions
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetDisplayUrl(this HttpRequest request)
|
public static string GetDisplayUrl(this HttpRequest request)
|
||||||
{
|
{
|
||||||
return request.Scheme + "://" + request.Host.Value + request.PathBase.Value + request.Path.Value + request.QueryString.Value;
|
return new StringBuilder()
|
||||||
|
.Append(request.Scheme)
|
||||||
|
.Append(SchemeDelimiter)
|
||||||
|
.Append(request.Host.Value)
|
||||||
|
.Append(request.PathBase.Value)
|
||||||
|
.Append(request.Path.Value)
|
||||||
|
.Append(request.QueryString.Value)
|
||||||
|
.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue