diff --git a/src/Illuminate/Routing/RouteGroup.php b/src/Illuminate/Routing/RouteGroup.php index 5b96469d092b..4dad20d3da7b 100644 --- a/src/Illuminate/Routing/RouteGroup.php +++ b/src/Illuminate/Routing/RouteGroup.php @@ -59,7 +59,7 @@ protected static function formatNamespace($new, $old) */ protected static function formatPrefix($new, $old, $prependExistingPrefix = true) { - $old = $old['prefix'] ?? null; + $old = $old['prefix'] ?? ''; if ($prependExistingPrefix) { return isset($new['prefix']) ? trim($old, '/').'/'.trim($new['prefix'], '/') : $old; diff --git a/tests/Routing/RouteRegistrarTest.php b/tests/Routing/RouteRegistrarTest.php index 2e451affaa7d..ce443e040c24 100644 --- a/tests/Routing/RouteRegistrarTest.php +++ b/tests/Routing/RouteRegistrarTest.php @@ -250,6 +250,16 @@ public function testCanRegisterGroupWithDomainAndNamePrefix() $this->assertSame('api.users', $this->getRoute()->getName()); } + public function testRouteGroupingWithoutPrefix() + { + $this->router->group([], function ($router) { + $router->prefix('bar')->get('baz', ['as' => 'baz', function () { + return 'hello'; + }]); + }); + $this->seeResponse('hello', Request::create('bar/baz', 'GET')); + } + public function testRegisteringNonApprovedAttributesThrows() { $this->expectException(BadMethodCallException::class);