mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Fix TemplateParserV1 and FrontEndFileHandler not recognizing Google webfonts '.../css2?...' URL as CSS
This commit is contained in:
parent
b591f023ef
commit
e2cfa524d0
4 changed files with 30 additions and 2 deletions
|
|
@ -209,7 +209,7 @@ class FrontEndFileHandler extends Handler
|
|||
$file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false;
|
||||
if ($file->isExternalURL && !$file->fileExtension)
|
||||
{
|
||||
$file->fileExtension = preg_match('/[\.\/](css|js)\b/', $fileName, $matches) ? $matches[1] : null;
|
||||
$file->fileExtension = preg_match('/[\.\/](css|js)[0-9]?\b/', $fileName, $matches) ? $matches[1] : null;
|
||||
}
|
||||
$file->isCachedScript = !$file->isExternalURL && strpos($file->filePath, 'files/cache/') !== false;
|
||||
$file->isCommon = $isCommon;
|
||||
|
|
|
|||
|
|
@ -628,7 +628,14 @@ class TemplateParser_v1
|
|||
$doUnload = ($m[3] === 'unload');
|
||||
$isRemote = !!preg_match('@^(https?:)?//@i', $attr['target']);
|
||||
|
||||
if(!$isRemote)
|
||||
if($isRemote)
|
||||
{
|
||||
if (empty($pathinfo['extension']))
|
||||
{
|
||||
$pathinfo['extension'] = preg_match('/[\.\/](css|js)[0-9]?\b/', $attr['target'], $mx) ? $mx[1] : null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (preg_match('!^\\^/(.+)!', $attr['target'], $tmatches))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -161,6 +161,17 @@ class FrontEndFileHandlerTest extends \Codeception\Test\Unit
|
|||
$this->assertEquals($expected, $handler->getCssFileList());
|
||||
}
|
||||
|
||||
public function testExternalFile5()
|
||||
{
|
||||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('https://fonts.googleapis.com/css?family=Montserrat&display=swap'));
|
||||
$handler->loadFile(array('//fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap'));
|
||||
|
||||
$expected[] = array('file' => 'https://fonts.googleapis.com/css?family=Montserrat&display=swap', 'media'=>'all');
|
||||
$expected[] = array('file' => '//fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap', 'media'=>'all');
|
||||
$this->assertEquals($expected, $handler->getCssFileList());
|
||||
}
|
||||
|
||||
public function testPathConversion()
|
||||
{
|
||||
$handler = new FrontEndFileHandler();
|
||||
|
|
|
|||
|
|
@ -118,6 +118,16 @@ class TemplateParserV1Test extends \Codeception\Test\Unit
|
|||
'<dummy /><load target="css/style.css" /><dummy />',
|
||||
'?><dummy /><!--#Meta:tests/_data/template/css/style.css--><?php Context::loadFile([\'tests/_data/template/css/style.css\', \'\', \'\', \'\', []]); ?><dummy />'
|
||||
),
|
||||
// <load target="https://fonts.googleapis.com/css?family=Montserrat&display=swap">
|
||||
array(
|
||||
'<dummy /><load target="https://fonts.googleapis.com/css?family=Montserrat&display=swap" /><dummy />',
|
||||
'?><dummy /><!--#Meta:https://fonts.googleapis.com/css?family=Montserrat&display=swap--><?php Context::loadFile([\'https://fonts.googleapis.com/css?family=Montserrat&display=swap\', \'\', \'tests\', \'\', []]); ?><dummy />'
|
||||
),
|
||||
// <load target="//fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap">
|
||||
array(
|
||||
'<dummy /><load target="//fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap" /><dummy />',
|
||||
'?><dummy /><!--#Meta://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap--><?php Context::loadFile([\'//fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap\', \'\', \'tests\', \'\', []]); ?><dummy />'
|
||||
),
|
||||
// <unload target="style.css">
|
||||
array(
|
||||
'<dummy /><unload target="css/style.css" /><dummy />',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue