Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing HtmlHelper::css, and JavascriptHelper::link so that files cont…

…aining the asset extension always get the extension added. Test cases added. Refs #139
  • Loading branch information...
commit c47e899ba1c62223a31746e44932fec0f7a7935a 1 parent f12cbdb
@markstory markstory authored
View
2  cake/libs/view/helpers/html.php
@@ -344,7 +344,7 @@ function css($path, $rel = null, $htmlAttributes = array(), $inline = true) {
}
if (strpos($path, '?') === false) {
- if (strpos($path, '.css') === false) {
+ if (substr($path, -4) !== '.css') {
$path .= '.css';
}
}
View
2  cake/libs/view/helpers/javascript.php
@@ -249,7 +249,7 @@ function link($url, $inline = true) {
$url = JS_URL . $url;
}
if (strpos($url, '?') === false) {
- if (strpos($url, '.js') === false) {
+ if (substr($url, -3) !== '.js') {
$url .= '.js';
}
}
View
4 cake/tests/cases/libs/view/helpers/html.test.php
@@ -362,6 +362,10 @@ function testCssLink() {
$result = $this->Html->css('screen.css');
$this->assertTags($result, $expected);
+ $result = $this->Html->css('my.css.library');
+ $expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/';
+ $this->assertTags($result, $expected);
+
$result = $this->Html->css('screen.css?1234');
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
$this->assertTags($result, $expected);
View
4 cake/tests/cases/libs/view/helpers/javascript.test.php
@@ -166,6 +166,10 @@ function testLink() {
$expected = '<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>';
$this->assertEqual($result, $expected);
+ $result = $this->Javascript->link('some.json.libary');
+ $expected = '<script type="text/javascript" src="js/some.json.libary.js"></script>';
+ $this->assertEqual($result, $expected);
+
$result = $this->Javascript->link('jquery-1.1.2');
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
$this->assertEqual($result, $expected);
Please sign in to comment.
Something went wrong with that request. Please try again.