Skip to content
Permalink
Browse files

Fixing querystring parameters being chopped off of absolute webroot a…

…sset paths.
  • Loading branch information...
markstory committed Feb 14, 2010
1 parent 6ccc43d commit f04add4f793aae4b67189b11ad485c5d697890e2
Showing with 14 additions and 10 deletions.
  1. +1 −1 cake/libs/view/helper.php
  2. +13 −9 cake/tests/cases/libs/view/helper.test.php
@@ -224,7 +224,7 @@ function webroot($file) {
}
}
if (strpos($webPath, '//') !== false) {
return str_replace('//', '/', $webPath);
return str_replace('//', '/', $webPath . $asset[1]);
}
return $webPath . $asset[1];
}
@@ -661,42 +661,46 @@ function testMultiDimensionalField() {
$result = $this->Helper->value('My.title');
$this->assertEqual($result,'My Title');
}
function testWebrootPaths() {
$this->Helper->webroot = '/';
$result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/img/cake.power.gif';
$this->assertEqual($result, $expected);
$this->Helper->theme = 'test_theme';
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/theme/test_theme/img/cake.power.gif';
$this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/test.jpg');
$expected = '/theme/test_theme/img/test.jpg';
$this->assertEqual($result, $expected);
$webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'webroot' . DS);
$result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/theme/test_theme/img/cake.power.gif';
$this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/test.jpg');
$expected = '/theme/test_theme/img/test.jpg';
$this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/cake.icon.gif');
$expected = '/img/cake.icon.gif';
$this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/cake.icon.gif?some=param');
$expected = '/img/cake.icon.gif?some=param';
$this->assertEqual($result, $expected);
Configure::write('App.www_root', $webRoot);
}

0 comments on commit f04add4

Please sign in to comment.
You can’t perform that action at this time.