Fixed issue with empty named parameters

pull/11/head
Mike Cao 14 years ago
parent 4b682b67c0
commit 853155b759

@ -36,7 +36,8 @@ class Router {
* Tries to match a requst to a route. Also parses named parameters in the url. * Tries to match a requst to a route. Also parses named parameters in the url.
* *
* @param string $pattern URL pattern * @param string $pattern URL pattern
* @param object $request Request object * @param string $url Request URL
* @param array $params Named URL parameters
*/ */
public function match($pattern, $url, array &$params = array()) { public function match($pattern, $url, array &$params = array()) {
$ids = array(); $ids = array();
@ -50,7 +51,7 @@ class Router {
else if ($str{0} == '@') { else if ($str{0} == '@') {
if (preg_match('/@(\w+)(\:([^\/]*))?/', $str, $matches)) { if (preg_match('/@(\w+)(\:([^\/]*))?/', $str, $matches)) {
$ids[$matches[1]] = true; $ids[$matches[1]] = true;
return '(?P<'.$matches[1].'>'.(isset($matches[3]) ? $matches[3] : '[^(\/|\?)]*').')'; return '(?P<'.$matches[1].'>'.(isset($matches[3]) ? $matches[3] : '[^(\/|\?)]+').')';
} }
} }
return $str; return $str;

Loading…
Cancel
Save