Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trim trailing slashes in shop url in before registration start l… #57

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/EventListener/BeforeRegistrationStartsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public function __invoke(BeforeRegistrationStartsEvent $event): void
$shop = $event->getShop();

try {
$this->httpClient->request('HEAD', sprintf("%s/api/_info/config", $shop->getShopUrl()), [
$shopUrl = rtrim($shop->getShopUrl(), '/');
$this->httpClient->request('HEAD', sprintf("%s/api/_info/config", $shopUrl), [
'timeout' => 10,
'max_redirects' => 0,
]);
Expand Down
6 changes: 3 additions & 3 deletions tests/EventListener/BeforeRegistrationStartsListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testListenerMustBeExecutedWithoutErrorsIfTheCheckIsSetToTrueInCo
$shop
->expects(self::once())
->method('getShopUrl')
->willReturn('https://shop-url.com');
->willReturn('https://shop-url.com/');

$this->httpClient
->expects(self::once())
Expand All @@ -80,13 +80,13 @@ public function testListenerMustBeExecutedWithoutErrorsIfTheCheckIsSetToTrueInCo
public function testListenerMustThrowExceptionBecauseTheShopURLIsNotReachable(): void
{
$this->expectException(ShopURLIsNotReachableException::class);
$this->expectExceptionMessage('Shop URL "https://shop-url.com" is not reachable from the application server.');
$this->expectExceptionMessage('Shop URL "https://shop-url.com/" is not reachable from the application server.');

$shop = $this->createMock(ShopInterface::class);
$shop
->expects(self::exactly(2))
->method('getShopUrl')
->willReturn('https://shop-url.com');
->willReturn('https://shop-url.com/');

$this->httpClient
->expects(self::once())
Expand Down
Loading