mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #735 from oddnoc/scheme-relative-requirements
Allow scheme-relative URLs in requirements
This commit is contained in:
commit
5c6707df89
@ -18,8 +18,10 @@ class RequirementsTest extends SapphireTest {
|
||||
|
||||
$backend->javascript('http://www.mydomain.com/test.js');
|
||||
$backend->javascript('https://www.mysecuredomain.com/test.js');
|
||||
$backend->javascript('//scheme-relative.example.com/test.js');
|
||||
$backend->css('http://www.mydomain.com/test.css');
|
||||
$backend->css('https://www.mysecuredomain.com/test.css');
|
||||
$backend->css('//scheme-relative.example.com/test.css');
|
||||
|
||||
$html = $backend->includeInHTML(false, self::$html_template);
|
||||
|
||||
@ -31,6 +33,10 @@ class RequirementsTest extends SapphireTest {
|
||||
(strpos($html, 'https://www.mysecuredomain.com/test.js') !== false),
|
||||
'Load external secure javascript URL'
|
||||
);
|
||||
$this->assertTrue(
|
||||
(strpos($html, '//scheme-relative.example.com/test.js') !== false),
|
||||
'Load external scheme-relative javascript URL'
|
||||
);
|
||||
$this->assertTrue(
|
||||
(strpos($html, 'http://www.mydomain.com/test.css') !== false),
|
||||
'Load external CSS URL'
|
||||
@ -39,6 +45,10 @@ class RequirementsTest extends SapphireTest {
|
||||
(strpos($html, 'https://www.mysecuredomain.com/test.css') !== false),
|
||||
'Load external secure CSS URL'
|
||||
);
|
||||
$this->assertTrue(
|
||||
(strpos($html, '//scheme-relative.example.com/test.css') !== false),
|
||||
'Load scheme-relative CSS URL'
|
||||
);
|
||||
}
|
||||
|
||||
protected function setupCombinedRequirements($backend) {
|
||||
|
@ -784,7 +784,7 @@ class Requirements_Backend {
|
||||
* @return string|boolean
|
||||
*/
|
||||
protected function path_for_file($fileOrUrl) {
|
||||
if(preg_match('/^http[s]?/', $fileOrUrl)) {
|
||||
if(preg_match('{^//|http[s]?}', $fileOrUrl)) {
|
||||
return $fileOrUrl;
|
||||
} elseif(Director::fileExists($fileOrUrl)) {
|
||||
$prefix = Director::baseURL();
|
||||
|
Loading…
Reference in New Issue
Block a user