From 15ff651e778951f410d833db7a6c8d8dac59710c Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Wed, 12 Mar 2025 21:02:03 -0400 Subject: [PATCH] support for duplicated slashes in nested groups --- flight/net/Route.php | 2 +- tests/FlightTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/flight/net/Route.php b/flight/net/Route.php index 8294a19..47f93dc 100644 --- a/flight/net/Route.php +++ b/flight/net/Route.php @@ -87,7 +87,7 @@ class Route */ public function __construct(string $pattern, $callback, array $methods, bool $pass, string $alias = '') { - $this->pattern = $pattern; + $this->pattern = str_replace('//', '/', $pattern); $this->callback = $callback; $this->methods = $methods; $this->pass = $pass; diff --git a/tests/FlightTest.php b/tests/FlightTest.php index 990bf93..0c9a7d7 100644 --- a/tests/FlightTest.php +++ b/tests/FlightTest.php @@ -134,6 +134,21 @@ class FlightTest extends TestCase Flight::start(); } + public function testStaticNestedGroups(): void { + Flight::group('/', static function (): void { + Flight::group('/', static function (): void { + Flight::route('GET /', static function (): void { + echo "test"; + }); + }); + }); + + Flight::request()->url = '/'; + + $this->expectOutputString('test'); + Flight::start(); + } + public function testStaticRouteGet() {