diff --git a/src/Service/Router/RoutingBuilder.php b/src/Service/Router/RoutingBuilder.php index 8d8700216..68e22a718 100644 --- a/src/Service/Router/RoutingBuilder.php +++ b/src/Service/Router/RoutingBuilder.php @@ -253,9 +253,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('-');