Skip to content

Commit

Permalink
Restored ability to link PHP files for CSS and JS from view helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Mar 31, 2010
1 parent f56e24c commit 7e277e8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/html.php
Expand Up @@ -343,7 +343,7 @@ function css($path, $rel = null, $htmlAttributes = array(), $inline = true) {
}

if (strpos($path, '?') === false) {
if (substr($path, -4) !== '.css') {
if (!preg_match('/.*\.(css|php)$/i', $path)) {
$path .= '.css';
}
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/javascript.php
Expand Up @@ -248,7 +248,7 @@ function link($url, $inline = true) {
$url = JS_URL . $url;
}
if (strpos($url, '?') === false) {
if (substr($url, -3) !== '.js') {
if (!preg_match('/.*\.(js|php)$/i', $url)) {
$url .= '.js';
}
}
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -365,6 +365,10 @@ function testCssLink() {
$expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/';
$this->assertTags($result, $expected);

$result = $this->Html->css('my.css.php');
$expected['link']['href'] = 'preg:/.*css\/my\.css\.php/';
$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: 2 additions & 2 deletions cake/tests/cases/libs/view/helpers/javascript.test.php
Expand Up @@ -173,8 +173,8 @@ function testLink() {
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.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>';
$result = $this->Javascript->link('jquery-1.1.2.php');
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.php"></script>';
$this->assertEqual($result, $expected);

$result = $this->Javascript->link('/plugin/js/jquery-1.1.2');
Expand Down

0 comments on commit 7e277e8

Please sign in to comment.