|
|
@ -86,9 +86,12 @@ class Router {
|
|
|
|
$str = '(.*)';
|
|
|
|
$str = '(.*)';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($str != null && $str{0} == '@') {
|
|
|
|
else if ($str != null && $str{0} == '@') {
|
|
|
|
if (preg_match('/@(\w+)(\:([^\/]*))?/', $str, $matches)) {
|
|
|
|
if (preg_match('/@(\w+)(\:([^\/]*))?([\(|\)]+)?/', $str, $matches)) {
|
|
|
|
$ids[$matches[1]] = true;
|
|
|
|
$ids[$matches[1]] = null;
|
|
|
|
return '(?P<'.$matches[1].'>'.(isset($matches[3]) ? $matches[3] : '[^(\/|\?)]+').')';
|
|
|
|
return '(?P<'.$matches[1].'>'
|
|
|
|
|
|
|
|
.(!empty($matches[3]) ? $matches[3] : '[^(\/|\?)]+')
|
|
|
|
|
|
|
|
.')'
|
|
|
|
|
|
|
|
.(!empty($matches[4]) ? str_replace(')',')?',$matches[4]) : '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $str;
|
|
|
|
return $str;
|
|
|
@ -99,7 +102,9 @@ class Router {
|
|
|
|
// Attempt to match route and named parameters
|
|
|
|
// Attempt to match route and named parameters
|
|
|
|
if (preg_match($regex, $url, $matches)) {
|
|
|
|
if (preg_match($regex, $url, $matches)) {
|
|
|
|
if (!empty($ids)) {
|
|
|
|
if (!empty($ids)) {
|
|
|
|
$this->params = array_intersect_key($matches, $ids);
|
|
|
|
foreach ($ids as $k => $v) {
|
|
|
|
|
|
|
|
$this->params[$k] = (array_key_exists($k, $matches)) ? $matches[$k] : null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->matched = $pattern;
|
|
|
|
$this->matched = $pattern;
|
|
|
|