改进路由规则定义的变量获取

This commit is contained in:
thinkphp
2016-03-25 17:03:30 +08:00
parent f85a2bfe98
commit 0ad3e4587a

View File

@@ -609,10 +609,18 @@ class Route
$val = str_replace('<' . $name . '>', '(' . $pattern[$name] . ')', $val);
}
}
if (!preg_match('/^' . $val . '$/', $m1[$key])) {
if (preg_match('/^' . $val . '$/', $m1[$key], $match)) {
array_shift($match);
foreach ($matches[1] as $i => $name) {
if (strpos($name, '?')) {
$name = substr($name, 0, -1);
}
$var[$name] = $match[$i];
}
continue;
} else {
return false;
}
continue;
}
if (0 === strpos($val, '[:')) {