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

[TASK] Normalize urls in all cases in order to avoid double slashes #597

Merged
merged 3 commits into from
Jun 20, 2023
Merged
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
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