Skip to content

Commit

Permalink
Allow only non-empty extension to check support
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Mar 5, 2023
1 parent b0aefcd commit 5395257
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Pug/PugSymfonyEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function exists($name): bool
public function supports($name): bool
{
foreach ($this->getOptionDefault('extensions', ['.pug', '.jade']) as $extension) {
if (str_ends_with($name, $extension)) {
if ($extension && str_ends_with($name, $extension)) {
return true;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Pug/Symfony/Traits/HelpersHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ protected function getHttpFoundationExtension(): HttpFoundationExtension
$stack = $this->stack ?? $this->container->get('request_stack');

/* @var RequestContext $context */
$context = $this->context ?? ($this->container->has('router.request_context')
? $this->container->get('router.request_context')
: $this->container->get('router')->getContext()
$context = $this->context ?? (
$this->container->has('router.request_context')
? $this->container->get('router.request_context')
: $this->container->get('router')->getContext()
);

return new HttpFoundationExtension(new UrlHelper($stack, $context));
Expand Down
8 changes: 4 additions & 4 deletions tests/Pug/PugSymfonyEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function testRequireTwig()
self::expectException(RuntimeException::class);
self::expectExceptionMessage('Twig needs to be configured.');

$object = new class () {
$object = new class() {
use HelpersHandler;

public function wrongEnhance(): void
Expand Down Expand Up @@ -382,7 +382,7 @@ public function testAssetHelperPhp()
'/<div( class="[^"]+")(.+?)></',
'<div$2$1><',
strtr(trim($pugSymfony->render('style-php.pug')), [
"\r" => '',
"\r" => '',
'&#039;' => "'",
]),
),
Expand Down Expand Up @@ -410,7 +410,7 @@ public function testAssetHelperJs()
'/<div( class="[^"]+")(.+?)></',
'<div$2$1><',
strtr(trim($pugSymfony->render('style-js.pug')), [
"\r" => '',
"\r" => '',
'&#039;' => "'",
]),
),
Expand Down Expand Up @@ -534,7 +534,7 @@ public function testCustomPaths()
public function testMissingDir()
{
self::expectExceptionObject(new CompilerException(
new SourceLocation('page.pug', 1,0),
new SourceLocation('page.pug', 1, 0),
'Source file page.pug not found',
));

Expand Down

0 comments on commit 5395257

Please sign in to comment.