From 1e21f9dae76070c578ffb64f4bc5fb7f0833688f Mon Sep 17 00:00:00 2001 From: anime Date: Mon, 20 Jan 2025 13:04:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B7=BB=E5=8A=A0=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=20checkStrIsUuid):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) {