Explorar el Código

Merge remote branch 'kriswallsmith/framework/protocol-relative-base-urls'

* kriswallsmith/framework/protocol-relative-base-urls:
  [Templating] updated assets helper to leave protocol-relative URLs untouched
  [FrameworkBundle] cleaned up test class
Fabien Potencier hace 14 años
padre
commit
06d00f36ba

+ 2 - 2
src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/CodeHelperTest.php

@@ -10,9 +10,10 @@
  */
 
 namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
+
 use Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper;
 
-class TemplateTest extends \PHPUnit_Framework_TestCase
+class CodeHelperTest extends \PHPUnit_Framework_TestCase
 {
     protected static $helper;
 
@@ -54,5 +55,4 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
             array('Method', '<abbr title="Method">Method</abbr>()')
         );
     }
-    
 }

+ 1 - 1
src/Symfony/Component/Templating/Helper/AssetsHelper.php

@@ -146,7 +146,7 @@ class AssetsHelper extends Helper implements AssetPackageInterface
      */
     public function getUrl($path, $packageName = null)
     {
-        if (false !== strpos($path, '://')) {
+        if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
             return $path;
         }
 

+ 6 - 0
tests/Symfony/Tests/Component/Templating/Helper/AssetsHelperTest.php

@@ -74,4 +74,10 @@ class AssetsHelperTest extends \PHPUnit_Framework_TestCase
         $helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd');
         $this->assertEquals('http://www.example.com/foo/foo.js?abcd', $helper->getUrl('foo.js'), '->getUrl() appends the version if defined');
     }
+
+    public function testGetUrlLeavesProtocolRelativePathsUntouched()
+    {
+        $helper = new AssetsHelper(null, 'http://foo.com');
+        $this->assertEquals('//bar.com/asset', $helper->getUrl('//bar.com/asset'));
+    }
 }