diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php
index 0b7324616..c8c055f16 100644
--- a/cake/libs/view/helpers/javascript.php
+++ b/cake/libs/view/helpers/javascript.php
@@ -129,7 +129,7 @@ class JavascriptHelper extends AppHelper {
return;
}
- if (strpos($url, '.') === false && strpos($url, '?') === false) {
+ if (strpos($url, '.js') === false && strpos($url, '?') === false) {
$url .= '.js';
}
if (strpos($url, '://') === false) {
diff --git a/cake/tests/cases/libs/view/helpers/javascript.test.php b/cake/tests/cases/libs/view/helpers/javascript.test.php
index 929c9cbf6..81effda0b 100644
--- a/cake/tests/cases/libs/view/helpers/javascript.test.php
+++ b/cake/tests/cases/libs/view/helpers/javascript.test.php
@@ -46,6 +46,24 @@ class JavascriptTest extends UnitTestCase {
$this->js->Form = new FormHelper();
}
+ function testLink() {
+ $result = $this->js->link('script.js');
+ $expected = '';
+ $this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
+
+ $result = $this->js->link('script');
+ $expected = '';
+ $this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
+
+ $result = $this->js->link('scriptaculous.js?load=effects');
+ $expected = '';
+ $this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
+
+ $result = $this->js->link('jquery-1.1.2');
+ $expected = '';
+ $this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
+ }
+
function testObjectGeneration() {
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));