OSDN Git Service

Merge pull request #68 from duylecampos/hotfix-1.1.2
[php-libraries/Router.git] / src / PHPRouter / Router.php
index fe61751..a307ae8 100755 (executable)
@@ -115,6 +115,7 @@ class Router
             if (!preg_match("@^" . $this->basePath . $routes->getRegex() . "*$@i", $requestUrl, $matches)) {
                 continue;
             }
+            $matchedText = array_shift($matches);
 
             $params = array();
 
@@ -122,6 +123,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])) {