Skip to content

Commit

Permalink
Fixing HtmlHelper::css, and JavascriptHelper::link so that files cont…
Browse files Browse the repository at this point in the history
…aining the asset extension always get the extension added. Test cases added. Refs #139
  • Loading branch information
markstory committed Oct 2, 2009
1 parent f12cbdb commit c47e899
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/html.php
Expand Up @@ -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';
}
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/javascript.php
Expand Up @@ -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';
}
}
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/view/helpers/javascript.test.php
Expand Up @@ -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);
Expand Down

0 comments on commit c47e899

Please sign in to comment.