mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-13 23:53:42 +08:00
update 优化 白名单支持对通配符路径匹配
This commit is contained in:
parent
0a5c72988a
commit
ffcb15ba96
@ -6,9 +6,10 @@
|
||||
*/
|
||||
export function isPathMatch(pattern: string, path: string) {
|
||||
const regexPattern = pattern
|
||||
.replace(/\//g, '\\/')
|
||||
.replace(/([.+^${}()|\[\]\\])/g, '\\$1')
|
||||
.replace(/\*\*/g, '__DOUBLE_STAR__')
|
||||
.replace(/\*/g, '[^\\/]*')
|
||||
.replace(/\?/g, '[^\\/]')
|
||||
.replace(/__DOUBLE_STAR__/g, '.*');
|
||||
const regex = new RegExp(`^${regexPattern}$`);
|
||||
return regex.test(path);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user