mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Simplify how fullBase is calculated.
Using FULL_BASE_URL fixes URL generation when URL rewriting is disabled. Fixes #3777
This commit is contained in:
parent
c327bdc4bd
commit
65b1a94e63
2 changed files with 16 additions and 6 deletions
|
@ -658,6 +658,21 @@ class HelperTest extends CakeTestCase {
|
|||
$this->assertEquals('foo.jpg?one=two&three=four', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assetUrl with no rewriting.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAssetUrlNoRewrite() {
|
||||
$this->Helper->request->addPaths(array(
|
||||
'base' => '/cake_dev/index.php',
|
||||
'webroot' => '/cake_dev/app/webroot/',
|
||||
'here' => '/cake_dev/index.php/tasks',
|
||||
));
|
||||
$result = $this->Helper->assetUrl('img/cake.icon.png', array('fullBase' => true));
|
||||
$this->assertEquals('http://localhost/cake_dev/app/webroot/img/cake.icon.png', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assetUrl with plugins.
|
||||
*
|
||||
|
|
|
@ -328,12 +328,7 @@ class Helper extends Object {
|
|||
$path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
|
||||
|
||||
if (!empty($options['fullBase'])) {
|
||||
$base = $this->url('/', true);
|
||||
$len = strlen($this->request->webroot);
|
||||
if ($len) {
|
||||
$base = substr($base, 0, -$len);
|
||||
}
|
||||
$path = $base . $path;
|
||||
$path = rtrim(FULL_BASE_URL, '/') . '/' . ltrim($path, '/');
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue