Skip to content

Commit

Permalink
fix array keys from cached routes (#42078)
Browse files Browse the repository at this point in the history
Introduced by #35714.
Removed the slash to match the same array key as in
src/Illuminate/Routing/RouteCollection.php:60
  • Loading branch information
glamorous committed Apr 25, 2022
1 parent 6fea6c2 commit d363435
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/Illuminate/Routing/CompiledRouteCollection.php
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Routing/CompiledRouteCollectionTest.php
Expand Up @@ -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());
Expand Down

0 comments on commit d363435

Please sign in to comment.