From 4cf069a5523409ff0efb02deedf08df5547b7d51 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 17 Jan 2013 16:29:36 -0800 Subject: [PATCH] Minor code changes. --- flight/net/Router.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/net/Router.php b/flight/net/Router.php index a344484..df94cc1 100644 --- a/flight/net/Router.php +++ b/flight/net/Router.php @@ -86,8 +86,7 @@ class Router { */ public function match($pattern, $url) { $ids = array(); - - // Convert optional parameters + $char = substr($pattern, -1); $pattern = str_replace(')', ')?', $pattern); // Build the regex for matching @@ -104,11 +103,11 @@ class Router { ); // Fix trailing slash - if (substr($pattern, -1) === '/') { + if ($char === '/') { $regex .= '?'; } // Replace wildcard - else if (substr($pattern, -1) === '*') { + else if ($char === '*') { $regex = str_replace('*', '.+?', $pattern); } // Allow trailing slash @@ -139,6 +138,7 @@ class Router { */ public function route(Request $request) { $this->matched = null; + $this->regex = null; $this->params = array(); $routes = isset($this->routes[$request->method]) ? $this->routes[$request->method] : array();