create-prisma-php-app 4.4.5-beta → 4.4.7-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -424,17 +424,22 @@ final class Bootstrap extends RuntimeException
424
424
  }
425
425
  }
426
426
  } elseif (strpos($normalizedRoute, '[...') !== false) {
427
- if (count($pathnameSegments) <= $expectedSegmentCount) {
427
+ $cleanedRoute = preg_replace('/\(.+\)/', '', $normalizedRoute);
428
+ $cleanedRoute = preg_replace('/\/+/', '/', $cleanedRoute);
429
+ $staticPart = preg_replace('/\[\.\.\..*?\].*/', '', $cleanedRoute);
430
+ $staticSegments = array_filter(explode('/', $staticPart));
431
+ $minRequiredSegments = count($staticSegments);
432
+
433
+ if (count($pathnameSegments) < $minRequiredSegments) {
428
434
  continue;
429
435
  }
430
436
 
431
- $cleanedNormalizedRoute = preg_replace('/\(.+\)/', '', $normalizedRoute);
432
- $cleanedNormalizedRoute = preg_replace('/\/+/', '/', $cleanedNormalizedRoute);
433
- $dynamicSegmentRoute = preg_replace('/\[\.\.\..*?\].*/', '', $cleanedNormalizedRoute);
437
+ $cleanedNormalizedRoute = $cleanedRoute;
438
+ $dynamicSegmentRoute = $staticPart;
434
439
 
435
440
  if (strpos("/src/app/$normalizedPathname", $dynamicSegmentRoute) === 0) {
436
441
  $trimmedPathname = str_replace($dynamicSegmentRoute, '', "/src/app/$normalizedPathname");
437
- $pathnameParts = explode('/', trim($trimmedPathname, '/'));
442
+ $pathnameParts = $trimmedPathname === '' ? [] : explode('/', trim($trimmedPathname, '/'));
438
443
 
439
444
  if (preg_match('/\[\.\.\.(.*?)\]/', $normalizedRoute, $matches)) {
440
445
  $dynamicParam = $matches[1];
@@ -451,18 +456,14 @@ final class Bootstrap extends RuntimeException
451
456
 
452
457
  if (strpos($normalizedRoute, 'index.php') !== false) {
453
458
  $segmentMatch = "[...$dynamicParam]";
454
- $index = array_search($segmentMatch, $filteredRouteSegments);
455
-
456
- if ($index !== false && isset($pathnameSegments[$index])) {
457
- $dynamicRoutePathname = str_replace($segmentMatch, implode('/', $pathnameParts), $cleanedNormalizedRoute);
458
- $dynamicRoutePathnameDirname = rtrim(dirname($dynamicRoutePathname), '/');
459
459
 
460
- $expectedPathname = rtrim("/src/app/$normalizedPathname", '/');
460
+ $dynamicRoutePathname = str_replace($segmentMatch, implode('/', $pathnameParts), $cleanedNormalizedRoute);
461
+ $dynamicRoutePathnameDirname = rtrim(dirname($dynamicRoutePathname), '/');
462
+ $expectedPathname = rtrim("/src/app/$normalizedPathname", '/');
461
463
 
462
- if ($expectedPathname === $dynamicRoutePathnameDirname) {
463
- $pathnameMatch = $normalizedRoute;
464
- break;
465
- }
464
+ if ($expectedPathname === $dynamicRoutePathnameDirname) {
465
+ $pathnameMatch = $normalizedRoute;
466
+ break;
466
467
  }
467
468
  }
468
469
  }