mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-19 19:20:49 +08:00
Fix wildcard exclusion regex escaping in auth files
This commit is contained in:
@@ -1022,8 +1022,12 @@ export function AuthFilesPage() {
|
|||||||
const excludedModels = excluded[providerKey] || excluded[providerType] || [];
|
const excludedModels = excluded[providerKey] || excluded[providerType] || [];
|
||||||
return excludedModels.some((pattern) => {
|
return excludedModels.some((pattern) => {
|
||||||
if (pattern.includes('*')) {
|
if (pattern.includes('*')) {
|
||||||
// 支持通配符匹配
|
// 支持通配符匹配:先转义正则特殊字符,再将 * 视为通配符
|
||||||
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$', 'i');
|
const regexSafePattern = pattern
|
||||||
|
.split('*')
|
||||||
|
.map((segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
||||||
|
.join('.*');
|
||||||
|
const regex = new RegExp(`^${regexSafePattern}$`, 'i');
|
||||||
return regex.test(modelId);
|
return regex.test(modelId);
|
||||||
}
|
}
|
||||||
return pattern.toLowerCase() === modelId.toLowerCase();
|
return pattern.toLowerCase() === modelId.toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user