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
…597)

Resolves: #596
  • Loading branch information
twoldanski authored Jun 20, 2023
1 parent 9b3768c commit 7079586
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Classes/Utility/UrlUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

use function array_merge;
use function count;
use function rtrim;
use function strpos;

Expand Down Expand Up @@ -186,7 +185,9 @@ private function resolveWithVariants(
array $variants = [],
string $returnField = 'frontendBase'
): string {
if (count($variants) === 0) {
$frontendUrl = rtrim($frontendUrl, '/');

if ($variants === []) {
return $frontendUrl;
}

Expand Down
12 changes: 6 additions & 6 deletions Tests/Unit/Utility/UrlUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ 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' => [
[
Expand Down Expand Up @@ -672,7 +672,7 @@ public function testEdgeCases()

$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

0 comments on commit 7079586

Please sign in to comment.