From cfc60228cf0d014a653a4643f43ba9d52e3315ba Mon Sep 17 00:00:00 2001 From: luzip665 Date: Mon, 17 Jan 2022 15:04:27 +0100 Subject: [PATCH] Running xhgui from subdir --- src/Twig/TwigExtension.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Twig/TwigExtension.php b/src/Twig/TwigExtension.php index 2cdac13e..322414ee 100755 --- a/src/Twig/TwigExtension.php +++ b/src/Twig/TwigExtension.php @@ -21,9 +21,6 @@ public function __construct(Router $router, Request $request, ?string $pathPrefi { $this->router = $router; $this->request = $request; - if (!$pathPrefix) { - $pathPrefix = ''; - } $this->pathPrefix = $pathPrefix; } @@ -81,7 +78,9 @@ public function url(string $name, $queryargs = []): string // this is copy of \Slim\Slim::urlFor() // to mix path prefix in \Slim\Slim::urlFor - return rtrim($this->pathPrefix, '/') . $this->router->urlFor($name) . $query; + $prepend = $this->pathPrefix ?: ''; + + return rtrim($prepend, '/') . $this->router->urlFor($name) . $query; } /** @@ -135,7 +134,7 @@ public function formatPercent($value): string private function pathPrefix(): string { - if ($this->pathPrefix !== '') { + if ($this->pathPrefix !== null) { return $this->pathPrefix; }