Skip to content

Commit

Permalink
Simplify how fullBase is calculated.
Browse files Browse the repository at this point in the history
Using FULL_BASE_URL fixes URL generation when URL rewriting is
disabled.

Fixes #3777
  • Loading branch information
markstory committed Apr 28, 2013
1 parent c327bdc commit 65b1a94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 15 additions & 0 deletions lib/Cake/Test/Case/View/HelperTest.php
Expand Up @@ -658,6 +658,21 @@ public function testAssetUrl() {
$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.
*
Expand Down
7 changes: 1 addition & 6 deletions lib/Cake/View/Helper.php
Expand Up @@ -328,12 +328,7 @@ public function assetUrl($path, $options = array()) {
$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;
}
Expand Down

0 comments on commit 65b1a94

Please sign in to comment.