mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing issue where JavascriptHelper::link was generating wrong URLs when webroot is defined and appending timestapping. Fixing issue in previous commit. Fixes #5723, fixes #5045
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7851 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
81e2f4a044
commit
e9953e3f93
3 changed files with 24 additions and 6 deletions
|
@ -355,7 +355,7 @@ class HtmlHelper extends AppHelper {
|
|||
$path = $this->webroot($path);
|
||||
$url = $path;
|
||||
|
||||
if ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
if (strpos($path, '?') === false && ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force')) {
|
||||
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,20 +258,21 @@ class JavascriptHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if (strpos($url, '://') === false) {
|
||||
if ($url{0} !== '/') {
|
||||
if ($url[0] !== '/') {
|
||||
$url = JS_URL . $url;
|
||||
}
|
||||
if (strpos($url, '?') === false) {
|
||||
if (strpos($url, '.js') === false) {
|
||||
$url .= '.js';
|
||||
}
|
||||
if ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
$url = $this->webroot($url);
|
||||
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->webroot($url);
|
||||
|
||||
if (strpos($url, '?') === false && ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force')) {
|
||||
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
|
||||
}
|
||||
|
||||
if (Configure::read('Asset.filter.js')) {
|
||||
$url = str_replace(JS_URL, 'cjs/', $url);
|
||||
}
|
||||
|
|
|
@ -241,6 +241,23 @@ class JavascriptTest extends CakeTestCase {
|
|||
Configure::delete('Asset.filter.js');
|
||||
}
|
||||
|
||||
$debug = Configure::read('debug');
|
||||
$webroot = $this->Javascript->webroot;
|
||||
|
||||
Configure::write('debug', 0);
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
|
||||
$this->Javascript->webroot = '/testing/';
|
||||
$result = $this->Javascript->link('__cake_js_test');
|
||||
$this->assertPattern('/^<script[^<>]+src="\/testing\/js\/__cake_js_test\.js\?"[^<>]*>/', $result);
|
||||
|
||||
$this->Javascript->webroot = '/testing/longer/';
|
||||
$result = $this->Javascript->link('__cake_js_test');
|
||||
$this->assertPattern('/^<script[^<>]+src="\/testing\/longer\/js\/__cake_js_test\.js\?"[^<>]*>/', $result);
|
||||
|
||||
$this->Javascript->webroot = $webroot;
|
||||
Configure::write('debug', $debug);
|
||||
|
||||
unlink(JS . '__cake_js_test.js');
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue