[+BUGFIX] Extbase (MVC): UriBuilder created URIs with a leading slash. Thanks to...
authorJochen Rau <j.rau@web.de>
Wed, 20 Jan 2010 10:45:14 +0000 (10:45 +0000)
committerJochen Rau <j.rau@web.de>
Wed, 20 Jan 2010 10:45:14 +0000 (10:45 +0000)
typo3/sysext/extbase/Classes/MVC/Web/Routing/UriBuilder.php
typo3/sysext/extbase/Tests/MVC/Web/Routing/UriBuilder_testcase.php

index 2b516b7..cf558d9 100644 (file)
@@ -483,6 +483,7 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder {
                $typolinkConfiguration = $this->buildTypolinkConfiguration();
 
                $uri = $this->contentObject->typoLink_URL($typolinkConfiguration);
+               $uri = ltrim($uri, '/');
                if ($this->createAbsoluteUri === TRUE) {
                        $uri = $this->request->getBaseURI() . $uri;
                }
index 47f6ded..1c7c7d5 100644 (file)
@@ -295,7 +295,19 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder_testcase extends Tx_Extbase_BaseTest
 
                $this->assertSame($expectedResult, $actualResult);
        }
+       
+       /**
+        * @test
+        */
+       public function buildFrontendUriStripsLeadingSlashesFromRelativeUris() {
+               $this->contentObject->expects($this->once())->method('typoLink_URL')->will($this->returnValue('/relative/uri'));
+
+               $expectedResult = 'relative/uri';
+               $actualResult = $this->uriBuilder->buildFrontendUri();
 
+               $this->assertSame($expectedResult, $actualResult);
+       }
+       
        /**
         * @test
         */