From 1c6586ae847c6003a169ef6b893c41f43e308ba9 Mon Sep 17 00:00:00 2001 From: Joe DeCock Date: Wed, 9 Oct 2024 08:54:01 -0500 Subject: [PATCH] Revert "Get the URL authority when retrieving it from the HttpClient BaseAddress" --- src/Client/Extensions/HttpClientDiscoveryExtensions.cs | 2 +- .../HttpClientExtensions/DiscoveryExtensionsTests.cs | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Client/Extensions/HttpClientDiscoveryExtensions.cs b/src/Client/Extensions/HttpClientDiscoveryExtensions.cs index 600448ed..25879a72 100644 --- a/src/Client/Extensions/HttpClientDiscoveryExtensions.cs +++ b/src/Client/Extensions/HttpClientDiscoveryExtensions.cs @@ -44,7 +44,7 @@ public static async Task GetDiscoveryDocumentAsync(th } else if (client is HttpClient httpClient && httpClient.BaseAddress != null) { - address = httpClient.BaseAddress!.GetLeftPart(UriPartial.Authority); + address = httpClient.BaseAddress!.AbsoluteUri; } else { diff --git a/test/UnitTests/HttpClientExtensions/DiscoveryExtensionsTests.cs b/test/UnitTests/HttpClientExtensions/DiscoveryExtensionsTests.cs index 29e4799b..2ae45c7d 100644 --- a/test/UnitTests/HttpClientExtensions/DiscoveryExtensionsTests.cs +++ b/test/UnitTests/HttpClientExtensions/DiscoveryExtensionsTests.cs @@ -74,15 +74,12 @@ public async Task Http_request_should_have_correct_format() } - [Theory] - [InlineData("https://demo.identityserver.io")] - [InlineData("https://demo.identityserver.io/api/v1/")] - [InlineData("https://demo.identityserver.io/.well-known/openid-configuration")] - public async Task Base_address_should_work(string baseAddress) + [Fact] + public async Task Base_address_should_work() { var client = new HttpClient(_successHandler) { - BaseAddress = new Uri(baseAddress) + BaseAddress = new Uri(_endpoint) }; var disco = await client.GetDiscoveryDocumentAsync();