1
0
forked from ruoyi/RuoYi-Vue

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

This commit is contained in:
RuoYi
2024-12-07 14:41:58 +08:00
parent aec1a93e16
commit 88f620c44d
2 changed files with 22 additions and 5 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
}
/**