Skip to content

Commit 15ff651

Browse files
committed
support for duplicated slashes in nested groups
1 parent 5425955 commit 15ff651

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

flight/net/Route.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Route
8787
*/
8888
public function __construct(string $pattern, $callback, array $methods, bool $pass, string $alias = '')
8989
{
90-
$this->pattern = $pattern;
90+
$this->pattern = str_replace('//', '/', $pattern);
9191
$this->callback = $callback;
9292
$this->methods = $methods;
9393
$this->pass = $pass;

tests/FlightTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ public function testStaticRouteGroup()
134134
Flight::start();
135135
}
136136

137+
public function testStaticNestedGroups(): void {
138+
Flight::group('/', static function (): void {
139+
Flight::group('/', static function (): void {
140+
Flight::route('GET /', static function (): void {
141+
echo "test";
142+
});
143+
});
144+
});
145+
146+
Flight::request()->url = '/';
147+
148+
$this->expectOutputString('test');
149+
Flight::start();
150+
}
151+
137152
public function testStaticRouteGet()
138153
{
139154

0 commit comments

Comments
 (0)