Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 1d870ed

Browse files
authored
Merge pull request #579 from 0xced/BaseAddressAuthority
Get the URL authority when retrieving it from the HttpClient BaseAddress
2 parents bfeab0b + 84424fd commit 1d870ed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Client/Extensions/HttpClientDiscoveryExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static async Task<DiscoveryDocumentResponse> GetDiscoveryDocumentAsync(th
4242
}
4343
else if (client is HttpClient httpClient)
4444
{
45-
address = httpClient.BaseAddress!.AbsoluteUri;
45+
address = httpClient.BaseAddress!.GetLeftPart(UriPartial.Authority);
4646
}
4747
else
4848
{

test/UnitTests/HttpClientExtensions/DiscoveryExtensionsTests.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ public async Task Http_request_should_have_correct_format()
7474
}
7575

7676

77-
[Fact]
78-
public async Task Base_address_should_work()
77+
[Theory]
78+
[InlineData("https://demo.identityserver.io")]
79+
[InlineData("https://demo.identityserver.io/api/v1/")]
80+
[InlineData("https://demo.identityserver.io/.well-known/openid-configuration")]
81+
public async Task Base_address_should_work(string baseAddress)
7982
{
8083
var client = new HttpClient(_successHandler)
8184
{
82-
BaseAddress = new Uri(_endpoint)
85+
BaseAddress = new Uri(baseAddress)
8386
};
8487

8588
var disco = await client.GetDiscoveryDocumentAsync();

0 commit comments

Comments
 (0)