修复框架鉴权报错
This commit is contained in:
@@ -204,7 +204,24 @@ if (!function_exists('get_controller_path')) {
|
||||
if (count($parts) < 2) {
|
||||
return $parts[0] ?? null;
|
||||
}
|
||||
return implode('/', array_slice($parts, 1, -1)) ?: $parts[1];
|
||||
$segments = array_slice($parts, 1, -1);
|
||||
if ($segments === []) {
|
||||
return $parts[1] ?? null;
|
||||
}
|
||||
// ThinkPHP 风格段 game.Config -> game/config,与 $request->controller 解析结果一致(否则权限节点对不上)
|
||||
$normalized = [];
|
||||
foreach ($segments as $seg) {
|
||||
if (str_contains($seg, '.')) {
|
||||
$dotPos = strpos($seg, '.');
|
||||
$mod = substr($seg, 0, $dotPos);
|
||||
$ctrl = substr($seg, $dotPos + 1);
|
||||
$normalized[] = strtolower($mod);
|
||||
$normalized[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $ctrl));
|
||||
} else {
|
||||
$normalized[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $seg));
|
||||
}
|
||||
}
|
||||
return implode('/', $normalized);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user