Fixing querystring parameters being chopped off of absolute webroot asset paths.

This commit is contained in:
Mark Story 2010-02-13 20:43:02 -05:00
parent 6ccc43d776
commit f04add4f79
2 changed files with 14 additions and 10 deletions

View file

@ -224,7 +224,7 @@ class Helper extends Overloadable {
} }
} }
if (strpos($webPath, '//') !== false) { if (strpos($webPath, '//') !== false) {
return str_replace('//', '/', $webPath); return str_replace('//', '/', $webPath . $asset[1]);
} }
return $webPath . $asset[1]; return $webPath . $asset[1];
} }

View file

@ -661,42 +661,46 @@ class HelperTest extends CakeTestCase {
$result = $this->Helper->value('My.title'); $result = $this->Helper->value('My.title');
$this->assertEqual($result,'My Title'); $this->assertEqual($result,'My Title');
} }
function testWebrootPaths() { function testWebrootPaths() {
$this->Helper->webroot = '/'; $this->Helper->webroot = '/';
$result = $this->Helper->webroot('/img/cake.power.gif'); $result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/img/cake.power.gif'; $expected = '/img/cake.power.gif';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$this->Helper->theme = 'test_theme'; $this->Helper->theme = 'test_theme';
App::build(array( App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
)); ));
$result = $this->Helper->webroot('/img/cake.power.gif'); $result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/theme/test_theme/img/cake.power.gif'; $expected = '/theme/test_theme/img/cake.power.gif';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/test.jpg'); $result = $this->Helper->webroot('/img/test.jpg');
$expected = '/theme/test_theme/img/test.jpg'; $expected = '/theme/test_theme/img/test.jpg';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$webRoot = Configure::read('App.www_root'); $webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'webroot' . DS); 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'); $result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/theme/test_theme/img/cake.power.gif'; $expected = '/theme/test_theme/img/cake.power.gif';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/test.jpg'); $result = $this->Helper->webroot('/img/test.jpg');
$expected = '/theme/test_theme/img/test.jpg'; $expected = '/theme/test_theme/img/test.jpg';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Helper->webroot('/img/cake.icon.gif'); $result = $this->Helper->webroot('/img/cake.icon.gif');
$expected = '/img/cake.icon.gif'; $expected = '/img/cake.icon.gif';
$this->assertEqual($result, $expected); $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); Configure::write('App.www_root', $webRoot);
} }