Skip to content

Commit

Permalink
Merge pull request #7 from utopia-php/fix-router-fix
Browse files Browse the repository at this point in the history
Minor fix for routing
  • Loading branch information
eldadfux authored Feb 28, 2021
2 parents 9af223a + 3f93341 commit 86e3f8f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,14 @@ public function run(Request $request, Response $response): self
return \strlen($b) - \strlen($a);
});

\uksort(self::$routes[$method], function (string $a, string $b) {
return \count(\explode('/', $b)) - \count(\explode('/', $a));
\uksort(self::$routes[$method], function ($a, $b) {
$result = \count(\explode('/', $b)) - \count(\explode('/', $a));

if($result === 0) {
return \substr_count($a, ':') - \substr_count($b, ':');
}

return $result;
});
}

Expand Down

0 comments on commit 86e3f8f

Please sign in to comment.