From 417bdb4514256fe925461fe96270beb906d0e633 Mon Sep 17 00:00:00 2001 From: burzum Date: Wed, 12 Aug 2009 16:08:31 +0200 Subject: [PATCH] Fixing building of the right vendor path in the dispatcher in the case the plugin name appears again in the path --- cake/dispatcher.php | 3 +-- cake/tests/cases/dispatcher.test.php | 15 +++++++++++++++ .../test_plugin/vendors/js/test_plugin/test.js | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 cake/tests/test_app/plugins/test_plugin/vendors/js/test_plugin/test.js diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 36a139eaf13..063bdf4588b 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -619,7 +619,7 @@ 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++) { @@ -627,7 +627,6 @@ function cached($url) { } } $paths = array_merge($paths, Configure::read('vendorPaths')); - foreach ($paths as $path) { if (is_file($path . $url) && file_exists($path . $url)) { $assetFile = $path . $url; diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index fd0fff3b9ff..725a1467fea 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1700,6 +1700,20 @@ 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(); @@ -1707,6 +1721,7 @@ function testStaticAssets() { $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(); diff --git a/cake/tests/test_app/plugins/test_plugin/vendors/js/test_plugin/test.js b/cake/tests/test_app/plugins/test_plugin/vendors/js/test_plugin/test.js new file mode 100644 index 00000000000..6db1d7d0268 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/vendors/js/test_plugin/test.js @@ -0,0 +1 @@ +alert("Test App"); \ No newline at end of file