Skip to content

Commit afb1ca7

Browse files
Copilothalter73
andcommitted
Use collection expression syntax and improve documentation
Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
1 parent d2e90fe commit afb1ca7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private async Task<string> GetAccessTokenAsync(HttpResponseMessage response, boo
244244
}
245245

246246
// Convert string URIs to Uri objects for the selector
247-
List<Uri> authServerUris = new();
247+
List<Uri> authServerUris = [];
248248
foreach (var serverUriString in availableAuthorizationServers)
249249
{
250250
if (!Uri.TryCreate(serverUriString, UriKind.Absolute, out var serverUri))
@@ -747,13 +747,17 @@ private static string NormalizeUri(Uri uri)
747747
/// Normalizes a URI string for consistent comparison.
748748
/// </summary>
749749
/// <param name="uriString">The URI string to normalize.</param>
750-
/// <returns>A normalized string representation of the URI.</returns>
750+
/// <returns>
751+
/// A normalized string representation of the URI. If the string is a valid absolute URI,
752+
/// it is parsed and normalized (scheme, host, port, and path without trailing slash).
753+
/// If the string is not a valid absolute URI, only the trailing slash is removed.
754+
/// </returns>
751755
private static string NormalizeUri(string uriString)
752756
{
753757
// Parse the string as a URI to normalize it
754758
if (!Uri.TryCreate(uriString, UriKind.Absolute, out var uri))
755759
{
756-
// If it's not a valid URI, return the string as-is
760+
// If it's not a valid URI, return the string with trailing slash removed
757761
return uriString.TrimEnd('/');
758762
}
759763

0 commit comments

Comments
 (0)