Fixed absolute_url for absolute paths
This commit is contained in:
parent
a630d87d57
commit
08aa7bc223
@ -67,10 +67,10 @@ class HttpFoundationExtension extends \Twig_Extension
|
||||
$prefix = substr($prefix, 0, $pos).'/';
|
||||
}
|
||||
|
||||
$path = $prefix.$path;
|
||||
return $request->getUriForPath($prefix.$path);
|
||||
}
|
||||
|
||||
return $request->getUriForPath($path);
|
||||
return $request->getSchemeAndHttpHost().$path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,21 @@ class HttpFoundationExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGenerateAbsoluteUrlWithScriptFileName()
|
||||
{
|
||||
$request = Request::create('http://localhost/app/web/app_dev.php');
|
||||
$request->server->set('SCRIPT_FILENAME', '/var/www/app/web/app_dev.php');
|
||||
|
||||
$stack = new RequestStack();
|
||||
$stack->push($request);
|
||||
$extension = new HttpFoundationExtension($stack);
|
||||
|
||||
$this->assertEquals(
|
||||
'http://localhost/app/web/bundles/framework/css/structure.css',
|
||||
$extension->generateAbsoluteUrl('/app/web/bundles/framework/css/structure.css')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getGenerateRelativePathData()
|
||||
*/
|
||||
|
Reference in New Issue
Block a user