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() {