diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 2ad237b6..7de6dab7 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -261,8 +261,13 @@ class Node extends HttpService */ public function addChild(Node $node, string $field): Node { - $this->childes[] = $node; - return $node; + /** @var Node $oLod */ + $oLod = $this->childes[$field] ?? null; + if (!empty($oLod)) { + $node = $oLod; + } + $this->childes[$field] = $node; + return $this->childes[$field]; } diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index be6cc170..9ba554e9 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -145,7 +145,7 @@ class Router extends HttpService implements RouterInterface { [$first, $explode] = $this->split($path); if (!isset(static::$nodes[$method]['/'])) { - static::$nodes[$method][$first] = $this->NodeInstance('/', 0, $method); + static::$nodes[$method]['/'] = $this->NodeInstance('/', 0, $method); } $parent = static::$nodes[$method]['/'];