Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify how fullBase is calculated.

Using FULL_BASE_URL fixes URL generation when URL rewriting is
disabled.

Fixes #3777
  • Loading branch information...
commit 65b1a94e637c1760fe3b351fde16458219d822b0 1 parent c327bdc
@markstory markstory authored
Showing with 16 additions and 6 deletions.
  1. +15 −0 lib/Cake/Test/Case/View/HelperTest.php
  2. +1 −6 lib/Cake/View/Helper.php
View
15 lib/Cake/Test/Case/View/HelperTest.php
@@ -659,6 +659,21 @@ public function testAssetUrl() {
}
/**
+ * 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.
*
* @return void
View
7 lib/Cake/View/Helper.php
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.