diff --git a/lib/utils/index.js b/lib/utils/index.js index 787dc90d..e12f2f85 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -104,6 +104,17 @@ export function checkStartWithHttp(str) { } } +// 检查一个字符串是否UUID https://ihateregex.io/expr/uuid/ +export function checkStrIsUuid(str) { + if (!str) { + return false + } + // 使用正则表达式进行匹配 + const regex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/ + return regex.test(str) +} + + // 检查一个字符串是否notionid : 32位,仅由数字英文构成 export function checkStrIsNotionId(str) { if (!str) {