From 0999aebc1f7d5a064ed57a152e4766b439196d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 7 Sep 2020 10:50:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Route/Router.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index d5244a15..4ae1917d 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -52,8 +52,18 @@ class Router extends Application implements RouterInterface // list($first, $explode) = $this->split($path); $paths = array_column($this->groupTacks, 'prefix'); - $path = implode('/', $paths) . '/' . ltrim($path, '/'); - + if (empty($paths)) { + $path = ltrim($path, '/'); + } else { + if ($path !== '/') { + $path = implode('/', $paths) . '/' . ltrim($path, '/'); + } else { + $path = implode('/', $paths); + } + } + if (empty($path)) { + $path = '/'; + } // $parent = $this->nodes[$method][$first] ?? null;