@@ -159,6 +159,7 @@ private function groupStaticRoutes(RouteCollection $collection): array
159
159
160
160
foreach ($ collection ->all () as $ name => $ route ) {
161
161
$ compiledRoute = $ route ->compile ();
162
+ $ staticPrefix = rtrim ($ compiledRoute ->getStaticPrefix (), '/ ' );
162
163
$ hostRegex = $ compiledRoute ->getHostRegex ();
163
164
$ regex = $ compiledRoute ->getRegex ();
164
165
if ($ hasTrailingSlash = '/ ' !== $ route ->getPath ()) {
@@ -173,17 +174,17 @@ private function groupStaticRoutes(RouteCollection $collection): array
173
174
if ($ hasTrailingSlash ) {
174
175
$ url = substr ($ url , 0 , -1 );
175
176
}
176
- foreach ($ dynamicRegex as list ($ hostRx , $ rx )) {
177
- if (preg_match ($ rx , $ url ) && (!$ host || !$ hostRx || preg_match ($ hostRx , $ host ))) {
178
- $ dynamicRegex [] = [$ hostRegex , $ regex ];
177
+ foreach ($ dynamicRegex as list ($ hostRx , $ rx, $ prefix )) {
178
+ if (( '' === $ prefix || 0 === strpos ( $ url , $ prefix )) && preg_match ($ rx , $ url ) && (!$ host || !$ hostRx || preg_match ($ hostRx , $ host ))) {
179
+ $ dynamicRegex [] = [$ hostRegex , $ regex, $ staticPrefix ];
179
180
$ dynamicRoutes ->add ($ name , $ route );
180
181
continue 2 ;
181
182
}
182
183
}
183
184
184
185
$ staticRoutes [$ url ][$ name ] = [$ route , $ hasTrailingSlash ];
185
186
} else {
186
- $ dynamicRegex [] = [$ hostRegex , $ regex ];
187
+ $ dynamicRegex [] = [$ hostRegex , $ regex, $ staticPrefix ];
187
188
$ dynamicRoutes ->add ($ name , $ route );
188
189
}
189
190
}
0 commit comments