From 8917efcc0aea1ae3fa69a56c33618e6d5a8fe9ee Mon Sep 17 00:00:00 2001 From: dho Date: Thu, 15 Mar 2007 16:37:46 +0000 Subject: [PATCH] Appending .js to strings like script-x.x.x in link() function git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4615 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/javascript.php | 2 +- .../libs/view/helpers/javascript.test.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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));