1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-09 09:56:53 +02:00

Use stripos to compare request method, instead of explode + in_array.

This commit is contained in:
Danny van Kooten
2015-11-03 08:13:51 +07:00
parent b0d115431e
commit 6fe6f4b196

View File

@@ -189,18 +189,9 @@ class AltoRouter {
} }
foreach($this->routes as $handler) { foreach($this->routes as $handler) {
list($method, $_route, $target, $name) = $handler; list($methods, $_route, $target, $name) = $handler;
$methods = explode('|', $method); $method_match = (stripos($methods, $requestMethod) !== false);
$method_match = false;
// Check if request method matches. If not, abandon early. (CHEAP)
foreach($methods as $method) {
if (strcasecmp($requestMethod, $method) === 0) {
$method_match = true;
break;
}
}
// Method did not match, continue to next route. // Method did not match, continue to next route.
if(!$method_match) continue; if(!$method_match) continue;