Skip to content

Commit 05fd0e5

Browse files
Update CaseHandlingUriBuilder.cs
1 parent a9b1cd3 commit 05fd0e5

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/ImageSharp.Web/CaseHandlingUriBuilder.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,12 @@ public static string Encode(CaseHandling handling, Uri uri)
156156
pathBase: PathString.FromUriComponent(uri),
157157
query: QueryString.FromUriComponent(uri));
158158
}
159-
else
160-
{
161-
Uri faux = new(FallbackBaseUri, uri);
162-
return BuildRelative(
163-
handling,
164-
path: PathString.FromUriComponent(faux),
165-
query: QueryString.FromUriComponent(faux));
166-
}
159+
160+
Uri faux = new(FallbackBaseUri, uri);
161+
return BuildRelative(
162+
handling,
163+
path: PathString.FromUriComponent(faux),
164+
query: QueryString.FromUriComponent(faux));
167165
}
168166

169167
/// <summary>
@@ -202,12 +200,12 @@ private static void InitializeAbsoluteUriString(Span<char> buffer, (bool Lower,
202200
int index = 0;
203201
ReadOnlySpan<char> pathBaseSpan = uriParts.PathBase.AsSpan();
204202

205-
if (uriParts.Path.Length > 0 && pathBaseSpan.Length > 0 && pathBaseSpan[pathBaseSpan.Length - 1] == '/')
203+
if (uriParts.Path.Length > 0 && pathBaseSpan.Length > 0 && pathBaseSpan[^1] == '/')
206204
{
207205
// If the path string has a trailing slash and the other string has a leading slash, we need
208206
// to trim one of them.
209207
// Trim the last slash from pathBase. The total length was decremented before the call to string.Create.
210-
pathBaseSpan = pathBaseSpan.Slice(0, pathBaseSpan.Length - 1);
208+
pathBaseSpan = pathBaseSpan[..^1];
211209
}
212210

213211
if (uriParts.Scheme.Length > 0)

0 commit comments

Comments
 (0)