Skip to content
Permalink
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...
markstory committed Oct 2, 2009
1 parent f12cbdb commit c47e899ba1c62223a31746e44932fec0f7a7935a
@@ -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';
}
}
@@ -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';
}
}
@@ -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);
@@ -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);

0 comments on commit c47e899

Please sign in to comment.
You can’t perform that action at this time.