Skip to content

Commit

Permalink
Fixed prefix group merging issue in the route collection's class
Browse files Browse the repository at this point in the history
  • Loading branch information
divineniiquaye committed Oct 10, 2022
1 parent cddc624 commit 4153a4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function populate(self $collection, bool $asGroup = false)
$this->add($route['path'], [], $route['handler']);
$this->routes[$this->defaultIndex] = \array_merge_recursive(
$this->routes[$this->defaultIndex],
\array_diff_key($route, ['path' => null, 'handler' => null])
\array_diff_key($route, ['path' => null, 'handler' => null, 'prefix' => null])
);
}
$this->asRoute = $asRoute;
Expand Down
28 changes: 11 additions & 17 deletions tests/RouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,16 @@
'web' => true,
],
],
[
'handler' => 'Home::ping',
'prefix' => '/api/ping',
'path' => '/api/ping',
'methods' => [
'GET' => true,
'HEAD' => true,
],
'name' => 'api.ping',
],
[
'handler' => 'Home::createProduct',
'prefix' => '/api/v1/product/create',
Expand Down Expand Up @@ -692,30 +702,14 @@
],
[
'handler' => 'Home::indexApi',
'prefix' => [
'/api',
null,
],
'prefix' => '/api',
'path' => '/api/',
'methods' => [
'GET' => true,
'HEAD' => true,
],
'name' => 'api.GET_HEAD_api_',
],
[
'handler' => 'Home::ping',
'prefix' => [
'/api/ping',
'/ping',
],
'path' => '/api/ping',
'methods' => [
'GET' => true,
'HEAD' => true,
],
'name' => 'api.ping',
],
[
'handler' => 'Home::productUpdate',
'prefix' => '/api/v1/product/update',
Expand Down

0 comments on commit 4153a4f

Please sign in to comment.