From f15adb44fbd5637910e5cba61240dcd654e5f35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Tue, 22 Feb 2022 15:15:55 +0100 Subject: [PATCH] [9.x] Fix route:list command output --- src/Illuminate/Foundation/Console/RouteListCommand.php | 2 +- tests/Testing/Console/RouteListCommandTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/RouteListCommand.php b/src/Illuminate/Foundation/Console/RouteListCommand.php index dacc2a38f48e..e40a71f38ea0 100644 --- a/src/Illuminate/Foundation/Console/RouteListCommand.php +++ b/src/Illuminate/Foundation/Console/RouteListCommand.php @@ -303,7 +303,7 @@ protected function forCli($routes) fn ($route) => array_merge($route, [ 'action' => $this->formatActionForCli($route), 'method' => $route['method'] == 'GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS' ? 'ANY' : $route['method'], - 'uri' => $route['domain'] ? ($route['domain'].'/'.$route['uri']) : $route['uri'], + 'uri' => $route['domain'] ? ($route['domain'].'/'.ltrim($route['uri'], '/')) : $route['uri'], ]), ); diff --git a/tests/Testing/Console/RouteListCommandTest.php b/tests/Testing/Console/RouteListCommandTest.php index 37c9d2845b69..2e984d02b903 100644 --- a/tests/Testing/Console/RouteListCommandTest.php +++ b/tests/Testing/Console/RouteListCommandTest.php @@ -35,6 +35,10 @@ protected function setUp(): void public function testDisplayRoutesForCli() { + $this->router->get('/', function () { + // + }); + $this->router->get('closure', function () { return new RedirectResponse($this->urlGenerator->signedRoute('signed-route')); }); @@ -42,6 +46,10 @@ public function testDisplayRoutesForCli() $this->router->get('controller-method/{user}', [FooController::class, 'show']); $this->router->post('controller-invokable', FooController::class); $this->router->domain('{account}.example.com')->group(function () { + $this->router->get('/', function () { + // + }); + $this->router->get('user/{id}', function ($account, $id) { // })->name('user.show')->middleware('web'); @@ -50,6 +58,8 @@ public function testDisplayRoutesForCli() $this->artisan(RouteListCommand::class) ->assertSuccessful() ->expectsOutput('') + ->expectsOutput(' GET|HEAD / ..................................................... ') + ->expectsOutput(' GET|HEAD {account}.example.com/ ................................ ') ->expectsOutput(' GET|HEAD closure ............................................... ') ->expectsOutput(' POST controller-invokable Illuminate\Tests\Testing\Console\…') ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\Tests\Testing\Cons…')