Skip to content

Commit

Permalink
Updated the default route matcher class with minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
divineniiquaye committed Apr 14, 2022
1 parent d5e0aed commit 5bc5bf6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/RouteMatcher.php
Expand Up @@ -144,6 +144,13 @@ protected function matchCollection(string $method, UriInterface $uri, RouteColle
continue;
}

[$pathRegex, $hostsRegex, $variables] = $this->optimized[$offset] ??= $this->compiler->compile($route);
$hostsVar = [];

if (!\preg_match($pathRegex, $requestPath, $matches, \PREG_UNMATCHED_AS_NULL)) {
continue;
}

if (!$route->hasMethod($method)) {
$requirements[0] = \array_merge($requirements[0] ?? [], $route->getMethods());
continue;
Expand All @@ -154,13 +161,6 @@ protected function matchCollection(string $method, UriInterface $uri, RouteColle
continue;
}

[$pathRegex, $hostsRegex, $variables] = $this->optimized[$offset] ??= $this->compiler->compile($route);
$hostsVar = [];

if (!\preg_match($pathRegex, $requestPath, $matches, \PREG_UNMATCHED_AS_NULL)) {
continue;
}

if (empty($hostsRegex) || $this->matchHost($hostsRegex, $uri, $hostsVar)) {
if (!empty($variables)) {
$matchInt = 0;
Expand Down

0 comments on commit 5bc5bf6

Please sign in to comment.