OSDN Git Service

Strips GET variables from URL before matching. Fixes #9
authorDanny van Kooten <dannyvankooten@gmail.com>
Sun, 8 Apr 2012 13:47:35 +0000 (15:47 +0200)
committerDanny van Kooten <dannyvankooten@gmail.com>
Sun, 8 Apr 2012 13:47:35 +0000 (15:47 +0200)
Router.php

index 3420fb3..52923d0 100644 (file)
@@ -68,8 +68,14 @@ class Router {
     */
     public function matchCurrentRequest() {
         $requestMethod = (isset($_POST['_method']) && ($_method = strtoupper($_POST['_method'])) && in_array($_method,array('PUT','DELETE'))) ? $_method : $_SERVER['REQUEST_METHOD'];
+        $requestUrl = $_SERVER['REQUEST_URI'];
 
-        return $this->match($_SERVER['REQUEST_URI'], $requestMethod);
+        // strip GET variables from URL
+        if(($pos = strpos($requestUrl, '?')) !== false) {
+            $requestUrl =  substr($requestUrl, 0, $pos);
+        }
+
+        return $this->match($requestUrl, $requestMethod);
     }
 
     /**