From fb7bca27eb17aedf33fe5a1e9be63eb43ec299eb Mon Sep 17 00:00:00 2001
From: QianRj <14974713+qianrj@user.noreply.gitee.com>
Date: 星期四, 06 二月 2025 20:20:40 +0800
Subject: [PATCH] fix 修复 路由守卫白名单通配符正则覆盖问题

---
 src/utils/validate.ts |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/utils/validate.ts b/src/utils/validate.ts
index f2da87b..e2886e4 100644
--- a/src/utils/validate.ts
+++ b/src/utils/validate.ts
@@ -1,4 +1,20 @@
 /**
+ * 璺緞鍖归厤鍣�
+ * @param {string} pattern
+ * @param {string} path
+ * @returns {Boolean}
+ */
+export function isPathMatch(pattern: string, path: string) {
+  const regexPattern = pattern
+    .replace(/\//g, '\\/')
+    .replace(/\*\*/g, '__DOUBLE_STAR__')
+    .replace(/\*/g, '[^\\/]*')
+    .replace(/__DOUBLE_STAR__/g, '.*');
+  const regex = new RegExp(`^${regexPattern}$`);
+  return regex.test(path);
+}
+
+/**
  * 鍒ゆ柇url鏄惁鏄痟ttp鎴杊ttps
  * @returns {Boolean}
  * @param url
@@ -68,7 +84,7 @@
  */
 export const validEmail = (email: string) => {
   const reg =
-    /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+    /^(([^<>()\]\\.,;:\s@"]+(\.[^<>()\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
   return reg.test(email);
 };
 

--
Gitblit v1.9.3