白名单支持对通配符路径匹配

This commit is contained in:
RuoYi
2024-12-04 08:51:17 +08:00
parent 6efceac460
commit 1810f30491
2 changed files with 23 additions and 6 deletions

View File

@ -1,3 +1,15 @@
/**
* 路径匹配器
* @param {string} pattern
* @param {string} path
* @returns {Boolean}
*/
export function isPathMatch(pattern, path) {
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*\*/g, '.*').replace(/\*/g, '[^\\/]*')
const regex = new RegExp(`^${regexPattern}$`)
return regex.test(path)
}
/**
* 判断value字符串是否为空
* @param {string} value
@ -5,9 +17,9 @@
*/
export function isEmpty(value) {
if (value == null || value == "" || value == undefined || value == "undefined") {
return true;
return true
}
return false;
return false
}
/**
@ -87,7 +99,7 @@ export function validEmail(email) {
* @returns {Boolean}
*/
export function isString(str) {
return typeof str === 'string' || str instanceof String;
return typeof str === 'string' || str instanceof String
}
/**