Refactoring Router.
This commit is contained in:
parent
775f11e09b
commit
f0b02caaec
|
@ -34,8 +34,8 @@ public static function route($method, $uri)
|
||||||
|
|
||||||
foreach (static::$routes as $keys => $callback)
|
foreach (static::$routes as $keys => $callback)
|
||||||
{
|
{
|
||||||
// Only check routes that have multiple URIs or wildcards. All other routes would have
|
// Only check routes that have multiple URIs or wildcards. All other routes would
|
||||||
// been caught by a literal match.
|
// have been caught by a literal match.
|
||||||
if (strpos($keys, '(') !== false or strpos($keys, ',') !== false )
|
if (strpos($keys, '(') !== false or strpos($keys, ',') !== false )
|
||||||
{
|
{
|
||||||
foreach (explode(', ', $keys) as $key)
|
foreach (explode(', ', $keys) as $key)
|
||||||
|
@ -44,6 +44,9 @@ public static function route($method, $uri)
|
||||||
|
|
||||||
if (preg_match('#^'.$key.'$#', $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)));
|
return Request::$route = new Route($keys, $callback, static::parameters(explode('/', $uri), explode('/', $key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue