diff --git a/src/Commands/Setup.php b/src/Commands/Setup.php index 45473a2af..b9c01f48b 100644 --- a/src/Commands/Setup.php +++ b/src/Commands/Setup.php @@ -211,7 +211,7 @@ private function setupRoutes() $file = 'Config/Routes.php'; $check = 'service(\'auth\')->routes($routes);'; - $pattern = '/(.*)(\n' . preg_quote('$routes->', '/') . '[^\n]+?\n)/su'; + $pattern = '/(.*)(\n' . preg_quote('$routes->', '/') . '[^\n]+?;\n)/su'; $replace = '$1$2' . "\n" . $check . "\n"; $this->add($file, $check, $pattern, $replace); diff --git a/tests/Commands/Setup/ContentReplacerTest.php b/tests/Commands/Setup/ContentReplacerTest.php index 7f750d75e..a861bc849 100644 --- a/tests/Commands/Setup/ContentReplacerTest.php +++ b/tests/Commands/Setup/ContentReplacerTest.php @@ -61,6 +61,11 @@ public function testAddAfter(): void $routes->get('/', 'Home::index'); + $routes->group('admin', static function ($routes) { + $routes->get('users', 'Admin\Users::index'); + $routes->get('blog', 'Admin\Blog::index'); + }); + /** * You will have access to the $routes object within that file without * needing to reload it. @@ -69,7 +74,7 @@ public function testAddAfter(): void FILE; $text = 'service(\'auth\')->routes($routes);'; - $pattern = '/(.*)(\n' . preg_quote('$routes->', '/') . '[^\n]+?\n)/su'; + $pattern = '/(.*)(\n' . preg_quote('$routes->', '/') . '[^\n]+?;\n)/su'; $replace = '$1$2' . "\n" . $text . "\n"; $output = $replacer->add($content, $text, $pattern, $replace); @@ -88,6 +93,11 @@ public function testAddAfter(): void service('auth')->routes($routes); + $routes->group('admin', static function ($routes) { + $routes->get('users', 'Admin\Users::index'); + $routes->get('blog', 'Admin\Blog::index'); + }); + /** * You will have access to the $routes object within that file without * needing to reload it.