Skip to content

Commit 90b0167

Browse files
committed
fix route caching attempt
1 parent f2b13b1 commit 90b0167

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: src/Illuminate/Routing/CompiledRouteCollection.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,15 @@ public function mapAttributesToRoutes()
222222
*/
223223
protected function newRoute(array $attributes)
224224
{
225-
$baseUri = ltrim(Str::replaceFirst(
226-
ltrim($attributes['action']['prefix'] ?? '', '/'),
227-
'',
228-
$attributes['uri']
229-
), '/');
225+
if (! empty($attributes['action']['prefix'] ?? '')) {
226+
$prefixSegments = explode('/', trim($attributes['action']['prefix'], '/'));
227+
228+
$baseUri = trim(implode(
229+
'/', array_slice(explode('/', trim($attributes['uri'], '/')), count($prefixSegments))
230+
), '/');
231+
} else {
232+
$baseUri = $attributes['uri'];
233+
}
230234

231235
return (new Route($attributes['methods'], $baseUri == '' ? '/' : $baseUri, $attributes['action']))
232236
->setFallback($attributes['fallback'])

0 commit comments

Comments
 (0)