diff --git a/public/locales/zh/dashboard.json b/public/locales/zh/dashboard.json index dcd290b1..d79e1536 100644 --- a/public/locales/zh/dashboard.json +++ b/public/locales/zh/dashboard.json @@ -130,5 +130,6 @@ "Got it, thanks!" : "好的,谢谢!", "Published!" : "已发布!", "Title goes here...": "标题在这里...", - "Start writing...": "开始写作..." + "Start writing...": "开始写作...", + "Slug can only contain letters, numbers, hyphens, and underscores." : "短链接只能包含字母、数字、连字符和下划线。" } \ No newline at end of file diff --git a/src/pages/dashboard/[subdomain]/editor.tsx b/src/pages/dashboard/[subdomain]/editor.tsx index 5298ee97..e1e4c646 100644 --- a/src/pages/dashboard/[subdomain]/editor.tsx +++ b/src/pages/dashboard/[subdomain]/editor.tsx @@ -140,6 +140,14 @@ export default function SubdomainEditor() { ), ) } + if (key === "slug" && !/^[a-zA-Z0-9\-_]*$/.test(value as string)) { + toast.error( + t( + "Slug can only contain letters, numbers, hyphens, and underscores.", + ), + ) + return + } const newValues = { ...values, [key]: value } if (draftKey) { setStorage(draftKey, {