From f0b02caaec832554cef17440a33069bbdf10e2f8 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 7 Jul 2011 09:34:58 -0700 Subject: [PATCH] Refactoring Router. --- system/router.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/router.php b/system/router.php index f3d5ed3b..d341b4a3 100644 --- a/system/router.php +++ b/system/router.php @@ -34,8 +34,8 @@ public static function route($method, $uri) foreach (static::$routes as $keys => $callback) { - // Only check routes that have multiple URIs or wildcards. All other routes would have - // been caught by a literal match. + // Only check routes that have multiple URIs or wildcards. All other routes would + // have been caught by a literal match. if (strpos($keys, '(') !== false or strpos($keys, ',') !== false ) { foreach (explode(', ', $keys) as $key) @@ -44,6 +44,9 @@ public static function route($method, $uri) if (preg_match('#^'.$key.'$#', $method.' '.$uri)) { + $uri = trim($uri, '/'); + $key = trim(substr($key, strlen($method.' ')), '/'); + return Request::$route = new Route($keys, $callback, static::parameters(explode('/', $uri), explode('/', $key))); } }