Skip to content

Commit ae2e9a9

Browse files
committed
改进路由中间件传参导致的问题
1 parent 5d42e53 commit ae2e9a9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/think/route/Dispatch.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ protected function doRouteAfter(): void
9898
// 添加中间件
9999
if (!empty($option['middleware'])) {
100100
if (isset($option['without_middleware'])) {
101-
$middleware = !empty($option['without_middleware']) ? array_diff($option['middleware'], $option['without_middleware']) : [];
101+
$middleware = [];
102+
foreach ($option['middleware'] as $item) {
103+
$middlewareName = is_array($item) ? $item[0] : $item;
104+
105+
if (!in_array($middlewareName, $option['without_middleware'], true)) {
106+
$middleware[] = $item;
107+
}
108+
}
102109
} else {
103110
$middleware = $option['middleware'];
104111
}

0 commit comments

Comments
 (0)