From 5b98b72bc5d98a68222a90993ffacc754e3ef948 Mon Sep 17 00:00:00 2001 From: Jonas De Smet Date: Thu, 21 Apr 2022 15:47:49 +0200 Subject: [PATCH] fix array keys from cached routes Introduced by https://github.com/laravel/framework/pull/35714. Removed the slash to match the same array key as in src/Illuminate/Routing/RouteCollection.php:60 --- src/Illuminate/Routing/CompiledRouteCollection.php | 6 +----- tests/Integration/Routing/CompiledRouteCollectionTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Routing/CompiledRouteCollection.php b/src/Illuminate/Routing/CompiledRouteCollection.php index 095d3a9b9fee..bb6d1e22d0f2 100644 --- a/src/Illuminate/Routing/CompiledRouteCollection.php +++ b/src/Illuminate/Routing/CompiledRouteCollection.php @@ -252,11 +252,7 @@ public function getRoutesByMethod() }) ->map(function (Collection $routes) { return $routes->mapWithKeys(function (Route $route) { - if ($domain = $route->getDomain()) { - return [$domain.'/'.$route->uri => $route]; - } - - return [$route->uri => $route]; + return [$route->getDomain().$route->uri => $route]; })->all(); }) ->all(); diff --git a/tests/Integration/Routing/CompiledRouteCollectionTest.php b/tests/Integration/Routing/CompiledRouteCollectionTest.php index 655be8dbe6aa..fcaa4dad5d4e 100644 --- a/tests/Integration/Routing/CompiledRouteCollectionTest.php +++ b/tests/Integration/Routing/CompiledRouteCollectionTest.php @@ -527,13 +527,13 @@ public function testRouteWithSamePathAndSameMethodButDiffDomainNameWithOptionsMe $this->assertEquals([ 'HEAD' => [ - 'foo.localhost/same/path' => $routes['foo_domain'], - 'bar.localhost/same/path' => $routes['bar_domain'], + 'foo.localhostsame/path' => $routes['foo_domain'], + 'bar.localhostsame/path' => $routes['bar_domain'], 'same/path' => $routes['no_domain'], ], 'GET' => [ - 'foo.localhost/same/path' => $routes['foo_domain'], - 'bar.localhost/same/path' => $routes['bar_domain'], + 'foo.localhostsame/path' => $routes['foo_domain'], + 'bar.localhostsame/path' => $routes['bar_domain'], 'same/path' => $routes['no_domain'], ], ], $this->collection()->getRoutesByMethod());