diff --git a/Classes/Utility/UrlUtility.php b/Classes/Utility/UrlUtility.php index 84c49352..cd0c9746 100644 --- a/Classes/Utility/UrlUtility.php +++ b/Classes/Utility/UrlUtility.php @@ -25,7 +25,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use function array_merge; -use function count; use function rtrim; use function strpos; @@ -186,7 +185,9 @@ private function resolveWithVariants( array $variants = [], string $returnField = 'frontendBase' ): string { - if (count($variants) === 0) { + $frontendUrl = rtrim($frontendUrl, '/'); + + if ($variants === []) { return $frontendUrl; } diff --git a/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php b/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php index c6b253f5..f3e85eaa 100644 --- a/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php +++ b/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php @@ -33,6 +33,9 @@ public function render() $json = $this->arguments['json']; if ($json === null) { $json = $this->renderChildren(); + if ($json !== null) { + $json = trim($json); + } if (empty($json)) { return null; } diff --git a/Tests/Unit/Utility/UrlUtilityTest.php b/Tests/Unit/Utility/UrlUtilityTest.php index 6f6fcf54..4706e0d8 100644 --- a/Tests/Unit/Utility/UrlUtilityTest.php +++ b/Tests/Unit/Utility/UrlUtilityTest.php @@ -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' => [ [ @@ -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 diff --git a/Tests/Unit/ViewHelpers/Format/Json/DecodeViewHelperTest.php b/Tests/Unit/ViewHelpers/Format/Json/DecodeViewHelperTest.php new file mode 100644 index 00000000..2579731a --- /dev/null +++ b/Tests/Unit/ViewHelpers/Format/Json/DecodeViewHelperTest.php @@ -0,0 +1,28 @@ +setArguments(['json' => null]); + $decodeViewHelper->setRenderChildrenClosure(function () { return "\n \n"; }); + $result = $decodeViewHelper->render(); + self::assertNull($result); + } +}