update 优化 白名单支持对通配符路径匹配
This commit is contained in:
@ -1,3 +1,15 @@
|
||||
/**
|
||||
* 路径匹配器
|
||||
* @param {string} pattern
|
||||
* @param {string} path
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function isPathMatch(pattern: string, path: string) {
|
||||
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*\*/g, '.*').replace(/\*/g, '[^\\/]*')
|
||||
const regex = new RegExp(`^${regexPattern}$`)
|
||||
return regex.test(path)
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断url是否是http或https
|
||||
* @returns {Boolean}
|
||||
|
Reference in New Issue
Block a user