From c2a8f39c17ab1b0a8a43849b6b82297ce08ddf0c Mon Sep 17 00:00:00 2001 From: Giuseppe Mazzapica Date: Wed, 13 Jul 2016 12:19:40 +0200 Subject: [PATCH] Do not check for uri chunks to parse route --- src/Cortex/Router/Router.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Cortex/Router/Router.php b/src/Cortex/Router/Router.php index f1e686a..f053c74 100644 --- a/src/Cortex/Router/Router.php +++ b/src/Cortex/Router/Router.php @@ -129,7 +129,7 @@ private function parseRoutes(UriInterface $uri, $httpMethod) /** @var \Brain\Cortex\Route\RouteInterface $route */ foreach ($iterator as $route) { $route = $this->sanitizeRouteMethod($this->groups->mergeGroup($route), $httpMethod); - if (! $this->validateRoute($route, $uri, $httpMethod)) { + if (! $this->validateRoute($route, $httpMethod)) { continue; } @@ -178,25 +178,20 @@ private function sanitizeRouteMethod(RouteInterface $route, $httpMethod) /** * @param \Brain\Cortex\Route\RouteInterface $route - * @param \Brain\Cortex\Uri\UriInterface $uri * @param $httpMethod * @return bool */ - private function validateRoute(RouteInterface $route, UriInterface $uri, $httpMethod) + private function validateRoute(RouteInterface $route, $httpMethod) { $id = $route->id(); $path = trim($route['path'], '/'); - if (count($uri->chunks()) !== (substr_count($path, '/') + 1)) { - return false; - } - $method = (array)$route['method']; $handler = $route['handler']; return is_string($id) && $id && filter_var($path, FILTER_SANITIZE_URL) === $path - && in_array($httpMethod, $method, true) + && in_array($httpMethod, (array) $route['method'], true) && (is_callable($handler) || $handler instanceof ControllerInterface); }