diff --git a/config/autoload/client-detection.global.php b/config/autoload/client-detection.global.php index c3d150bc..edbebf69 100644 --- a/config/autoload/client-detection.global.php +++ b/config/autoload/client-detection.global.php @@ -16,11 +16,4 @@ return [ ], ], - 'host_resolution' => [ - 'headers_to_inspect' => [ - 'Host', - 'X-Forwarded-Host', - ], - ], - ]; diff --git a/module/Core/src/Action/AbstractTrackingAction.php b/module/Core/src/Action/AbstractTrackingAction.php index 6bd3995a..db23c286 100644 --- a/module/Core/src/Action/AbstractTrackingAction.php +++ b/module/Core/src/Action/AbstractTrackingAction.php @@ -53,11 +53,12 @@ abstract class AbstractTrackingAction implements MiddlewareInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $shortCode = $request->getAttribute('shortCode', ''); + $domain = $request->getUri()->getAuthority(); $query = $request->getQueryParams(); $disableTrackParam = $this->appOptions->getDisableTrackParam(); try { - $url = $this->urlShortener->shortCodeToUrl($shortCode); + $url = $this->urlShortener->shortCodeToUrl($shortCode, $domain); // Track visit to this short code if ($disableTrackParam === null || ! array_key_exists($disableTrackParam, $query)) { diff --git a/module/Core/test/Action/PixelActionTest.php b/module/Core/test/Action/PixelActionTest.php index 9fce8f0e..8e2ecc7f 100644 --- a/module/Core/test/Action/PixelActionTest.php +++ b/module/Core/test/Action/PixelActionTest.php @@ -41,7 +41,7 @@ class PixelActionTest extends TestCase public function imageIsReturned(): void { $shortCode = 'abc123'; - $this->urlShortener->shortCodeToUrl($shortCode)->willReturn( + $this->urlShortener->shortCodeToUrl($shortCode, '')->willReturn( new ShortUrl('http://domain.com/foo/bar') )->shouldBeCalledOnce(); $this->visitTracker->track(Argument::cetera())->shouldBeCalledOnce(); diff --git a/module/Core/test/Action/RedirectActionTest.php b/module/Core/test/Action/RedirectActionTest.php index da2199e4..e0477b02 100644 --- a/module/Core/test/Action/RedirectActionTest.php +++ b/module/Core/test/Action/RedirectActionTest.php @@ -47,8 +47,8 @@ class RedirectActionTest extends TestCase $shortCode = 'abc123'; $expectedUrl = 'http://domain.com/foo/bar'; $shortUrl = new ShortUrl($expectedUrl); - $this->urlShortener->shortCodeToUrl($shortCode)->willReturn($shortUrl) - ->shouldBeCalledOnce(); + $this->urlShortener->shortCodeToUrl($shortCode, '')->willReturn($shortUrl) + ->shouldBeCalledOnce(); $this->visitTracker->track(Argument::cetera())->shouldBeCalledOnce(); $request = (new ServerRequest())->withAttribute('shortCode', $shortCode); @@ -64,8 +64,8 @@ class RedirectActionTest extends TestCase public function nextMiddlewareIsInvokedIfLongUrlIsNotFound(): void { $shortCode = 'abc123'; - $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(EntityDoesNotExistException::class) - ->shouldBeCalledOnce(); + $this->urlShortener->shortCodeToUrl($shortCode, '')->willThrow(EntityDoesNotExistException::class) + ->shouldBeCalledOnce(); $this->visitTracker->track(Argument::cetera())->shouldNotBeCalled(); $handler = $this->prophesize(RequestHandlerInterface::class); @@ -81,7 +81,7 @@ class RedirectActionTest extends TestCase public function redirectToCustomUrlIsReturnedIfConfiguredSoAndShortUrlIsNotFound(): void { $shortCode = 'abc123'; - $shortCodeToUrl = $this->urlShortener->shortCodeToUrl($shortCode)->willThrow( + $shortCodeToUrl = $this->urlShortener->shortCodeToUrl($shortCode, '')->willThrow( EntityDoesNotExistException::class ); @@ -106,8 +106,8 @@ class RedirectActionTest extends TestCase $shortCode = 'abc123'; $expectedUrl = 'http://domain.com/foo/bar'; $shortUrl = new ShortUrl($expectedUrl); - $this->urlShortener->shortCodeToUrl($shortCode)->willReturn($shortUrl) - ->shouldBeCalledOnce(); + $this->urlShortener->shortCodeToUrl($shortCode, '')->willReturn($shortUrl) + ->shouldBeCalledOnce(); $this->visitTracker->track(Argument::cetera())->shouldNotBeCalled(); $request = (new ServerRequest())->withAttribute('shortCode', $shortCode)