Skip to content

Commit

Permalink
Merge pull request #3271 from papparazzo/prevent_multiple_entries_of_…
Browse files Browse the repository at this point in the history
…same_method

prevent multiple entries of same methode in FastRouteDispatcher
  • Loading branch information
l0gicgate committed Jul 23, 2023
2 parents 8298785 + 40ed473 commit 3cf4c99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Slim/Routing/FastRouteDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ public function getAllowedMethods(string $uri): array
return $this->allowedMethods[$uri];
}

$this->allowedMethods[$uri] = [];
$allowedMethods = [];
foreach ($this->staticRouteMap as $method => $uriMap) {
if (isset($uriMap[$uri])) {
$this->allowedMethods[$uri][] = $method;
$allowedMethods[$method] = true;
}
}

foreach ($this->variableRouteData as $method => $routeData) {
$result = $this->dispatchVariableRoute($routeData, $uri);
if ($result[0] === self::FOUND) {
$this->allowedMethods[$uri][] = $method;
$allowedMethods[$method] = true;
}
}

return $this->allowedMethods[$uri];
return $this->allowedMethods[$uri] = array_keys($allowedMethods);
}
}

0 comments on commit 3cf4c99

Please sign in to comment.