From a65e4ba1c899a89cc6811eb5a5ee3779a2dd0ce6 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 31 Mar 2011 21:22:59 +0000 Subject: [PATCH] Fixed null array error. Added check for catchall route. --- flight/Router.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flight/Router.php b/flight/Router.php index 3b8afed..bac7e8e 100644 --- a/flight/Router.php +++ b/flight/Router.php @@ -1,6 +1,6 @@ * @license http://www.opensource.org/licenses/mit-license.php @@ -72,10 +72,10 @@ class Router { */ public function route(&$request) { $params = array(); - $routes = $this->routes[$request->method] + ($this->routes['*'] ?: array()); + $routes = ($this->routes[$request->method] ?: array()) + ($this->routes['*'] ?: array()); foreach ($routes as $pattern => $callback) { - if ($request->url === $pattern || self::match($pattern, $request->url, $params)) { + if ($pattern === '*' || $request->url === $pattern || self::match($pattern, $request->url, $params)) { $request->matched = $pattern; return array($callback, array($params)); }