From 7273f78b27b7504bcaeced57bcb1add2f9beb88d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 22 Jul 2016 12:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRoute=E7=B1=BB=E7=9A=84match?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index 4a4aa930..7d5faa76 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -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;