Skip to content

Commit

Permalink
NTR - optimizes custom domain overwrite (#883)
Browse files Browse the repository at this point in the history
* NTR - optimizes custom domain overwrite

* NTR - adjusts unit test
  • Loading branch information
michnhokn authored Nov 4, 2024
1 parent 4b0ee02 commit 4e9b41f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/Service/Router/RoutingBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Service/Routing/RoutingBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('-');

Expand Down

0 comments on commit 4e9b41f

Please sign in to comment.