Skip to content

Commit

Permalink
Fixing building of the right vendor path in the dispatcher in the cas…
Browse files Browse the repository at this point in the history
…e the plugin name appears again in the path
  • Loading branch information
burzum committed Aug 12, 2009
1 parent 9363a61 commit 417bdb4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cake/dispatcher.php
Expand Up @@ -619,15 +619,14 @@ function cached($url) {

if ($pos > 0) {
$plugin = substr($url, 0, $pos - 1);
$url = str_replace($plugin . '/', '', $url);
$url = preg_replace('/^' . preg_quote($plugin) . '\//i', '', $url);
$pluginPaths = Configure::read('pluginPaths');
$count = count($pluginPaths);
for ($i = 0; $i < $count; $i++) {
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS;
}
}
$paths = array_merge($paths, Configure::read('vendorPaths'));

foreach ($paths as $path) {
if (is_file($path . $url) && file_exists($path . $url)) {
$assetFile = $path . $url;
Expand Down
15 changes: 15 additions & 0 deletions cake/tests/cases/dispatcher.test.php
Expand Up @@ -1700,13 +1700,28 @@ function testStaticAssets() {
$this->assertEqual('this is the test asset css file', $result);


ob_start();
$Dispatcher->cached('test_plugin/js/test_plugin/test.js');
$result = ob_get_clean();
$this->assertEqual('alert("Test App");', $result);


Configure::write('debug', 0);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js');
ob_start();
$Dispatcher->cached('test_plugin/js/test_plugin/test.js');
$result = ob_get_clean();
$this->assertEqual('alert("Test App");', $result);


Configure::write('debug', 0);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css');
ob_start();
$Dispatcher->cached('test_plugin/css/test_plugin_asset.css');
$result = ob_get_clean();
$this->assertEqual('this is the test plugin asset css file', $result);


Configure::write('debug', 0);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif');
ob_start();
Expand Down
@@ -0,0 +1 @@
alert("Test App");

0 comments on commit 417bdb4

Please sign in to comment.