From 532b189d338f5eb80200c4fda8bb75b317ff54e8 Mon Sep 17 00:00:00 2001 From: Duyle Campos Date: Wed, 4 Nov 2015 19:21:49 -0200 Subject: [PATCH] Refactor route to check number of parameters received --- src/PHPRouter/Router.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PHPRouter/Router.php b/src/PHPRouter/Router.php index 595e434..d7a4fd9 100755 --- a/src/PHPRouter/Router.php +++ b/src/PHPRouter/Router.php @@ -110,6 +110,7 @@ class Router if (! preg_match("@^" . $this->basePath . $routes->getRegex() . "*$@i", $requestUrl, $matches)) { continue; } + $matchedText = array_shift($matches); $params = array(); @@ -118,6 +119,11 @@ class Router // grab array with matches $argument_keys = $argument_keys[1]; + // check arguments number + if(count($argument_keys) != count($matches)) { + continue; + } + // loop trough parameter names, store matching value in $params array foreach ($argument_keys as $key => $name) { if (isset($matches[$key + 1])) { -- 2.11.0