From 93f034b9bdfbf0f3c4c88a38af3a0bf57d2bfa3b Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 2 Jan 2008 19:32:46 +0000 Subject: [PATCH] Fixing JavascriptHelper::link() for script files outside of webroot/js (i.e. plugins), fixes #3799 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6313 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/javascript.php | 5 ++++- cake/tests/cases/libs/view/helpers/javascript.test.php | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index 39f4287d7..e9e6ab4b9 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -162,7 +162,10 @@ class JavascriptHelper extends AppHelper { } if (strpos($url, '://') === false) { - $url = $this->webroot(JS_URL . $url); + if ($url{0} !== '/') { + $url = JS_URL . $url; + } + $url = $this->webroot($url); if (Configure::read('Asset.filter.js')) { $url = str_replace(JS_URL, 'cjs/', $url); diff --git a/cake/tests/cases/libs/view/helpers/javascript.test.php b/cake/tests/cases/libs/view/helpers/javascript.test.php index e9afb55fc..923b6e505 100644 --- a/cake/tests/cases/libs/view/helpers/javascript.test.php +++ b/cake/tests/cases/libs/view/helpers/javascript.test.php @@ -80,6 +80,10 @@ class JavascriptTest extends UnitTestCase { $result = $this->Javascript->link('jquery-1.1.2'); $this->assertPattern('/^]+src=".*cjs\/jquery-1\.1\.2\.js"[^<>]*>/', $result); Configure::write('Asset.filter.js', false); + + $result = $this->Javascript->link('/plugin/js/jquery-1.1.2'); + $expected = ''; + $this->assertEqual($result, $expected); } function testObjectGeneration() {