diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 9046c279418..c1bfc29544f 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -617,7 +617,7 @@ function asset($url) { if ($parts[0] === 'theme') { $pos = strlen($parts[0] . $parts[1]) + 1; - } elseif (count($parts) > 2) { + } else { $pos = strlen($parts[0]); } $assetFile = null; diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 9cbc28afc60..f44a815f771 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1904,6 +1904,12 @@ function testAssets() { $result = ob_get_clean(); $this->assertEqual('nested theme js file', $result); + ob_start(); + $Dispatcher->asset('test_plugin/root.js'); + $result = ob_get_clean(); + $expected = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'root.js'); + $this->assertEqual($result, $expected); + ob_start(); $Dispatcher->dispatch('test_plugin/flash/plugin_test.swf'); $result = ob_get_clean(); diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/root.js b/cake/tests/test_app/plugins/test_plugin/webroot/root.js new file mode 100644 index 00000000000..529e1c18c65 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/webroot/root.js @@ -0,0 +1 @@ +alert('I am a root level file!'); \ No newline at end of file