Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Fixing a bug in case of a Optional Route Subpattern
Browse files Browse the repository at this point in the history
As described in #16 (comment)
  • Loading branch information
tomvb authored Sep 26, 2024
1 parent a2a8143 commit e6c03f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Router/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private static function findRoute(
// Extract the matched URL parameters (and only the parameters)
$params = array_map(function ($match, $index) use ($matches) {
// We have a following parameter: take the substring from the current param position until the next one's position (thank you PREG_OFFSET_CAPTURE)
if (isset($matches[$index + 1]) && isset($matches[$index + 1][0]) && is_array($matches[$index + 1][0])) {
if (isset($matches[$index + 1]) && isset($matches[$index + 1][0]) && $matches[$index + 1][0][1] != -1 && is_array($matches[$index + 1][0])) {
return trim(substr($match[0][0], 0, $matches[$index + 1][0][1] - $match[0][1]), '/');
}

Expand Down

0 comments on commit e6c03f4

Please sign in to comment.