改进Route类的match方法

This commit is contained in:
thinkphp
2016-07-22 12:50:07 +08:00
parent b54cc49d18
commit 7273f78b27

View File

@@ -1112,11 +1112,15 @@ class Route
if (0 === strpos($val, '[:')) {
// 可选参数
$val = substr($val, 1, -1);
$val = substr($val, 1, -1);
$optional = true;
}
if (0 === strpos($val, ':')) {
// URL变量
$name = substr($val, 1);
if (!isset($optional) && !isset($m1[$key])) {
return false;
}
if (isset($m1[$key]) && isset($pattern[$name]) && !preg_match('/^' . $pattern[$name] . '$/', $m1[$key])) {
// 检查变量规则
return false;