Skip to content

Commit a72ea47

Browse files
committed
fix: spark routes filters output
1 parent 9287cb0 commit a72ea47

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public function get(): array
9090

9191
foreach ($routes as $item) {
9292
$route = $item['route'] . $item['route_params'];
93+
94+
// For module routing
9395
if ($this->prefix !== '' && $route === '/') {
9496
$route = $this->prefix;
9597
} elseif ($this->prefix !== '') {
@@ -115,13 +117,22 @@ private function addFilters($routes)
115117
$filterCollector = new FilterCollector(true);
116118

117119
foreach ($routes as &$route) {
120+
$routePath = $route['route'];
121+
122+
// For module routing
123+
if ($this->prefix !== '' && $route === '/') {
124+
$routePath = $this->prefix;
125+
} elseif ($this->prefix !== '') {
126+
$routePath = $this->prefix . '/' . $routePath;
127+
}
128+
118129
// Search filters for the URI with all params
119130
$sampleUri = $this->generateSampleUri($route);
120-
$filtersLongest = $filterCollector->get($route['method'], $route['route'] . $sampleUri);
131+
$filtersLongest = $filterCollector->get($route['method'], $routePath . $sampleUri);
121132

122133
// Search filters for the URI without optional params
123134
$sampleUri = $this->generateSampleUri($route, false);
124-
$filtersShortest = $filterCollector->get($route['method'], $route['route'] . $sampleUri);
135+
$filtersShortest = $filterCollector->get($route['method'], $routePath . $sampleUri);
125136

126137
// Get common array elements
127138
$filters['before'] = array_intersect($filtersLongest['before'], $filtersShortest['before']);

0 commit comments

Comments
 (0)