diff --git a/src/Service/Router/RoutingBuilder.php b/src/Service/Router/RoutingBuilder.php index 5a9e651b0..6daaf6168 100644 --- a/src/Service/Router/RoutingBuilder.php +++ b/src/Service/Router/RoutingBuilder.php @@ -257,9 +257,7 @@ private function applyCustomDomain(string $url): string # then always use this one and override existing ones if ($customDomain !== '') { $components = parse_url($url); - $host = (is_array($components) && isset($components['host'])) ? (string)$components['host'] : ''; - # replace old domain with new custom domain - $url = str_replace($host, $customDomain, $url); + $url = $customDomain . ($components['path'] ?? ''); } return $url; diff --git a/tests/PHPUnit/Service/Routing/RoutingBuilderTest.php b/tests/PHPUnit/Service/Routing/RoutingBuilderTest.php index 4290ea003..323403537 100644 --- a/tests/PHPUnit/Service/Routing/RoutingBuilderTest.php +++ b/tests/PHPUnit/Service/Routing/RoutingBuilderTest.php @@ -57,7 +57,7 @@ public function testWebhookUrlWithCustomDomain(): void # prepare our fake server data # assign a current domain to replace. # also configure our environment variable - $builder = $this->createBuilder('https://local.mollie.shop/notify/123', '123.eu.ngrok.io'); + $builder = $this->createBuilder('https://local.mollie.shop/notify/123', 'https://123.eu.ngrok.io'); $url = $builder->buildWebhookURL('-');