Files
gsfdc/demo-dify/dify/web/utils/official-link.ts
T
wuzilongandCursor c2cb845a32 feat(dify): 把本地控制台的中文与去外链改动入库
这些界面改动和专家服务草稿停在工作区,没有随上一笔主分支提交进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-23 09:44:09 +08:00

19 lines
443 B
TypeScript

const OFFICIAL_HOST = /(^|\.)dify\.(ai|com)$/i
export function isOfficialDifyUrl(value?: string | null): boolean {
const trimmed = value?.trim() ?? ''
if (!trimmed) return false
const mailto = trimmed.match(/^mailto:([^?]+)/i)
if (mailto) {
const host = mailto[1]?.split('@').pop() ?? ''
return OFFICIAL_HOST.test(host)
}
try {
return OFFICIAL_HOST.test(new URL(trimmed).hostname)
} catch {
return false
}
}