66using System . Runtime . CompilerServices ;
77using Microsoft . AspNetCore . Http ;
88
9- namespace SixLabors . ImageSharp . Web . Caching
9+ namespace SixLabors . ImageSharp . Web
1010{
1111 /// <summary>
12- /// Optimized helper methods for generating cache keys from URI components. Much of this code has been adapted from the MIT licensed .NET runtime.
12+ /// Optimized helper methods for generating encoded Uris from URI components.
13+ /// Much of this code has been adapted from the MIT licensed .NET runtime.
1314 /// </summary>
14- internal static class CacheKeyHelper
15+ public static class CaseHandlingUriBuilder
1516 {
1617 private static readonly SpanAction < char , ( bool LowerInvariant , string Host , string PathBase , string Path , string Query ) > InitializeAbsoluteUriStringSpanAction = new ( InitializeAbsoluteUriString ) ;
1718
19+ /// <summary>
20+ /// Provides Uri case handling options.
21+ /// </summary>
1822 public enum CaseHandling
1923 {
24+ /// <summary>
25+ /// No adjustments to casing are made.
26+ /// </summary>
2027 None ,
28+
29+ /// <summary>
30+ /// All URI components are converted to lower case using the invariant culture before combining.
31+ /// </summary>
2132 LowerInvariant
2233 }
2334
@@ -29,14 +40,14 @@ public enum CaseHandling
2940 /// <param name="path">The portion of the request path that identifies the requested resource.</param>
3041 /// <param name="query">The query, if any.</param>
3142 /// <returns>The combined URI components, properly encoded for use in HTTP headers.</returns>
32- public static string BuildRelativeKey (
43+ public static string BuildRelative (
3344 CaseHandling handling ,
3445 PathString pathBase = default ,
3546 PathString path = default ,
3647 QueryString query = default )
3748
3849 // Take any potential performance hit vs concatination for code reading sanity.
39- => BuildAbsoluteKey ( handling , default , pathBase , path , query ) ;
50+ => BuildAbsolute ( handling , default , pathBase , path , query ) ;
4051
4152 /// <summary>
4253 /// Combines the given URI components into a string that is properly encoded for use in HTTP headers.
@@ -48,7 +59,7 @@ public static string BuildRelativeKey(
4859 /// <param name="path">The portion of the request path that identifies the requested resource.</param>
4960 /// <param name="query">The query, if any.</param>
5061 /// <returns>The combined URI components, properly encoded for use in HTTP headers.</returns>
51- public static string BuildAbsoluteKey (
62+ public static string BuildAbsolute (
5263 CaseHandling handling ,
5364 HostString host ,
5465 PathString pathBase = default ,
@@ -113,7 +124,7 @@ private static int CopyTextToBufferLowerInvariant(Span<char> buffer, int index,
113124 => index + text . ToLowerInvariant ( buffer . Slice ( index , text . Length ) ) ;
114125
115126 /// <summary>
116- /// Initializes the URI <see cref="string"/> for <see cref="BuildAbsoluteKey (CaseHandling, HostString, PathString, PathString, QueryString)"/>.
127+ /// Initializes the URI <see cref="string"/> for <see cref="BuildAbsolute (CaseHandling, HostString, PathString, PathString, QueryString)"/>.
117128 /// </summary>
118129 /// <param name="buffer">The URI <see cref="string"/>'s <see cref="char"/> buffer.</param>
119130 /// <param name="uriParts">The URI parts.</param>
0 commit comments