Skip to content

Commit

Permalink
[TASK] Normalize urls in all cases in order to avoid double slashes (#…
Browse files Browse the repository at this point in the history
…598)

Resolves: #596
  • Loading branch information
twoldanski authored Jun 19, 2023
1 parent c82db94 commit b5bbef7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions Classes/Utility/UrlUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private function resolveWithVariants(
array $variants = [],
string $returnField = 'frontendBase'
): string {
$frontendUrl = rtrim($frontendUrl, '/');
if ($variants === []) {
return $frontendUrl;
}
Expand Down
30 changes: 15 additions & 15 deletions Tests/Unit/Utility/UrlUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ public function testFrontendUrlsWithBaseProductionAndLocalOverride(): void
{
$site = $this->prophesize(Site::class);
$site->getConfiguration()->shouldBeCalled(3)->willReturn([
'base' => 'https://api.typo3.org',
'frontendBase' => 'https://www.typo3.org',
'frontendApiProxy' => 'https://www.typo3.org/headless',
'frontendFileApi' => 'https://www.typo3.org/headless/fileadmin',
'SpecialSitemapKey' => 'https://www.typo3.org/custom-sitemap',
'base' => 'https://api.typo3.org/',
'frontendBase' => 'https://www.typo3.org/',
'frontendApiProxy' => 'https://www.typo3.org/headless/',
'frontendFileApi' => 'https://www.typo3.org/headless/fileadmin/',
'SpecialSitemapKey' => 'https://www.typo3.org/custom-sitemap/',
'languages' => [],
'baseVariants' => [
[
'base' => 'https://test-backend-api.tld',
'condition' => 'applicationContext == "Development"',
'frontendBase' => 'https://test-frontend.tld',
'frontendApiProxy' => 'https://test-frontend-api.tld/headless',
'frontendFileApi' => 'https://test-frontend-api.tld/headless/fileadmin',
'SpecialSitemapKey' => 'https://test-frontend.tld/sitemap',
'frontendBase' => 'https://test-frontend.tld/',
'frontendApiProxy' => 'https://test-frontend-api.tld/headless/',
'frontendFileApi' => 'https://test-frontend-api.tld/headless/fileadmin/',
'SpecialSitemapKey' => 'https://test-frontend.tld/sitemap/',
],
]
]);
Expand Down Expand Up @@ -722,17 +722,17 @@ public function testEdgeCases()
'hreflang' => 'en-us',
'direction' => 'ltr',
'flag' => 'us',
'frontendBase' => 'https://frontend-domain-from-lang.tld',
'frontendBase' => 'https://frontend-domain-from-lang.tld/',
'frontendApiProxy' => 'https://frontend-domain-from-lang.tld/headless/',
'frontendFileApi' => 'https://frontend-domain-from-lang.tld/headless/fileadmin',
'frontendFileApi' => 'https://frontend-domain-from-lang.tld/headless/fileadmin/',
]));

$resolver = $this->prophesize(Resolver::class);
$resolver->evaluate(Argument::any())->willReturn(true);

$urlUtility = new UrlUtility(null, $resolver->reveal(), $siteFinder, $request->reveal());
self::assertSame('https://frontend-domain-from-lang.tld', $urlUtility->getFrontendUrl());
self::assertSame('https://frontend-domain-from-lang.tld/headless/', $urlUtility->getProxyUrl());
self::assertSame('https://frontend-domain-from-lang.tld/headless', $urlUtility->getProxyUrl());
self::assertSame('https://frontend-domain-from-lang.tld/headless/fileadmin', $urlUtility->getStorageProxyUrl());

// configuration on language lvl with variants
Expand Down Expand Up @@ -794,9 +794,9 @@ public function testEdgeCases()
[
'base' => 'https://test-backend-api.tld',
'condition' => 'applicationContext == "Development"',
'frontendBase' => 'https://test-frontend-from-from-request-lang.tld',
'frontendApiProxy' => 'https://test-frontend-from-from-request-lang.tld/headless',
'frontendFileApi' => 'https://test-frontend-from-from-request-lang.tld/headless/fileadmin'
'frontendBase' => 'https://test-frontend-from-from-request-lang.tld/',
'frontendApiProxy' => 'https://test-frontend-from-from-request-lang.tld/headless/',
'frontendFileApi' => 'https://test-frontend-from-from-request-lang.tld/headless/fileadmin/'
],
],
]));
Expand Down

0 comments on commit b5bbef7

Please sign in to comment.