Skip to content

Commit d5b3224

Browse files
committed
Use Uri::host
1 parent 4612db8 commit d5b3224

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Tracing/HttpClient/AbstractTraceableHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ public function setLogger(LoggerInterface $logger): void
115115
private function formatUri(Uri $uri): string
116116
{
117117
// Instead of relying on Uri::__toString, we only use a sub set of the URI
118-
return Uri::composeComponents($uri->getScheme(), $uri->getAuthority(), $uri->getPath(), null, null);
118+
return Uri::composeComponents($uri->getScheme(), $uri->getHost(), $uri->getPath(), null, null);
119119
}
120120
}

tests/Tracing/HttpClient/TraceableHttpClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public function testRequest(): void
6363
$mockResponse = new MockResponse();
6464
$decoratedHttpClient = new MockHttpClient($mockResponse);
6565
$httpClient = new TraceableHttpClient($decoratedHttpClient, $this->hub);
66-
$response = $httpClient->request('GET', 'https://www.example.com/test-page?foo=bar#baz');
66+
$response = $httpClient->request('GET', 'https://username:password@www.example.com/test-page?foo=bar#baz');
6767

6868
$this->assertInstanceOf(AbstractTraceableResponse::class, $response);
6969
$this->assertSame(200, $response->getStatusCode());
7070
$this->assertSame('GET', $response->getInfo('http_method'));
71-
$this->assertSame('https://www.example.com/test-page?foo=bar#baz', $response->getInfo('url'));
71+
$this->assertSame('https://username:password@www.example.com/test-page?foo=bar#baz', $response->getInfo('url'));
7272
$this->assertSame(['sentry-trace: ' . $transaction->toTraceparent()], $mockResponse->getRequestOptions()['normalized_headers']['sentry-trace']);
7373
$this->assertArrayNotHasKey('baggage', $mockResponse->getRequestOptions()['normalized_headers']);
7474
$this->assertNotNull($transaction->getSpanRecorder());

0 commit comments

Comments
 (0)