diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index 9a688f22e..f53b5595d 100644 --- a/src/Bridges/ApplicationTracy/RoutingPanel.php +++ b/src/Bridges/ApplicationTracy/RoutingPanel.php @@ -87,22 +87,24 @@ public function getPanel(): string */ private function analyse( Routing\Router $router, - Nette\Http\IRequest $httpRequest, + ?Nette\Http\IRequest $httpRequest, string $module = '', ?string $path = null, - bool $parentMatches = true, int $level = -1, int $flag = 0 ): void { if ($router instanceof Routing\RouteList) { - try { - $parentMatches = $parentMatches && $router->match($httpRequest) !== null; - } catch (\Throwable $e) { + if ($httpRequest) { + try { + $httpRequest = $router->match($httpRequest) === null ? null : $httpRequest; + } catch (\Throwable $e) { + $httpRequest = null; + } } $prop = (new \ReflectionProperty(Routing\RouteList::class, 'path')); $prop->setAccessible(true); - if ($pathPrefix = $prop->getValue($router)) { + if ($httpRequest && ($pathPrefix = $prop->getValue($router))) { $path .= $pathPrefix; $url = $httpRequest->getUrl(); $httpRequest = $httpRequest->withUrl($url->withPath($url->getPath(), $url->getBasePath() . $pathPrefix)); @@ -113,7 +115,7 @@ private function analyse( $next = count($this->routers); $flags = $router->getFlags(); foreach ($router->getRouters() as $i => $subRouter) { - $this->analyse($subRouter, $httpRequest, $module, $path, $parentMatches, $level + 1, $flags[$i]); + $this->analyse($subRouter, $httpRequest, $module, $path, $level + 1, $flags[$i]); } if ($info = $this->routers[$next] ?? null) { @@ -130,7 +132,7 @@ private function analyse( $matched = $flag & Routing\RouteList::ONE_WAY ? 'oneway' : 'no'; $params = $e = null; try { - $params = $parentMatches + $params = $httpRequest ? $router->match($httpRequest) : null; } catch (\Throwable $e) {