Bladeren bron

[DomCrawler] trim URI in getURI

stealth35 13 jaren geleden
bovenliggende
commit
a245e15434

+ 1 - 1
src/Symfony/Component/DomCrawler/Link.php

@@ -77,7 +77,7 @@ class Link
      */
     public function getUri()
     {
-        $uri = $this->getRawUri();
+        $uri = trim($this->getRawUri());
 
         // absolute URL?
         if ('http' === substr($uri, 0, 4)) {

+ 4 - 0
tests/Symfony/Tests/Component/DomCrawler/LinkTest.php

@@ -79,6 +79,10 @@ class LinkTest extends \PHPUnit_Framework_TestCase
         return array(
             array('/foo', 'http://localhost/bar/foo/', 'http://localhost/foo'),
             array('/foo', 'http://localhost/bar/foo', 'http://localhost/foo'),
+            array('
+            /foo', 'http://localhost/bar/foo/', 'http://localhost/foo'),
+            array('/foo
+            ', 'http://localhost/bar/foo', 'http://localhost/foo'),
 
             array('foo', 'http://localhost/bar/foo/', 'http://localhost/bar/foo/foo'),
             array('foo', 'http://localhost/bar/foo', 'http://localhost/bar/foo'),