Pre Merge pull request !181 from QianRj/dev

This commit is contained in:
QianRj 2025-02-06 12:23:53 +00:00 committed by Gitee
commit f23f820cf7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -5,9 +5,13 @@
* @returns {Boolean} * @returns {Boolean}
*/ */
export function isPathMatch(pattern: string, path: string) { export function isPathMatch(pattern: string, path: string) {
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*\*/g, '.*').replace(/\*/g, '[^\\/]*') const regexPattern = pattern
const regex = new RegExp(`^${regexPattern}$`) .replace(/\//g, '\\/')
return regex.test(path) .replace(/\*\*/g, '__DOUBLE_STAR__')
.replace(/\*/g, '[^\\/]*')
.replace(/__DOUBLE_STAR__/g, '.*');
const regex = new RegExp(`^${regexPattern}$`);
return regex.test(path);
} }
/** /**