mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed error if JS/CSS requirements have arguments. Ticket #3860. Thanks simon_w!
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@74961 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
bdce229639
commit
3235288080
@ -703,10 +703,15 @@ class Requirements_Backend {
|
||||
} elseif(Director::fileExists($fileOrUrl)) {
|
||||
$prefix = Director::absoluteBaseURL();
|
||||
$mtimesuffix = "";
|
||||
$suffix = '';
|
||||
if(strpos($fileOrUrl, '?') !== false) {
|
||||
$suffix = '&' . substr($fileOrUrl, strpos($fileOrUrl, '?')+1);
|
||||
$fileOrUrl = substr($fileOrUrl, 0, strpos($fileOrUrl, '?'));
|
||||
}
|
||||
if(Requirements::get_suffix_requirements()) {
|
||||
$mtimesuffix = "?m=" . filemtime(Director::baseFolder() . '/' . $fileOrUrl);
|
||||
}
|
||||
return "{$prefix}{$fileOrUrl}{$mtimesuffix}";
|
||||
return "{$prefix}{$fileOrUrl}{$mtimesuffix}{$suffix}";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -111,6 +111,26 @@ class RequirementsTest extends SapphireTest {
|
||||
Requirements::delete_combined_files('RequirementsTest_bc.js');
|
||||
}
|
||||
|
||||
function testArgsInUrls() {
|
||||
// Clear previous requirements
|
||||
Requirements::clear();
|
||||
|
||||
// clearing all previously generated requirements (just in case)
|
||||
Requirements::clear_combined_files();
|
||||
Requirements::delete_combined_files('RequirementsTest_bc.js');
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/tests/forms/RequirementsTest_a.js?test=1&test=2&test=3');
|
||||
Requirements::css(SAPPHIRE_DIR . '/tests/forms/RequirementsTest_a.css?test=1&test=2&test=3');
|
||||
|
||||
$html = Requirements::includeInHTML(false, self::$html_template);
|
||||
|
||||
/* Javascript has correct path */
|
||||
$this->assertTrue((bool)preg_match('/src=".*\/RequirementsTest_a\.js\?m=\d\d+&test=1&test=2&test=3/', $html), 'javascript has correct path');
|
||||
|
||||
/* CSS has correct path */
|
||||
$this->assertTrue((bool)preg_match('/href=".*\/RequirementsTest_a\.css\?m=\d\d+&test=1&test=2&test=3/', $html), 'css has correct path');
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a bit of a hack, as it alters the Requirements
|
||||
* statics globally for all tests.
|
||||
|
Loading…
Reference in New Issue
Block a user