feat: restrict the allowed characters for slug
This commit is contained in:
parent
11fc759533
commit
8324beaa09
|
|
@ -130,5 +130,6 @@
|
|||
"Got it, thanks!" : "好的,谢谢!",
|
||||
"Published!" : "已发布!",
|
||||
"Title goes here...": "标题在这里...",
|
||||
"Start writing...": "开始写作..."
|
||||
"Start writing...": "开始写作...",
|
||||
"Slug can only contain letters, numbers, hyphens, and underscores." : "短链接只能包含字母、数字、连字符和下划线。"
|
||||
}
|
||||
|
|
@ -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, {
|
||||
|
|
|
|||
Loading…
Reference in New Issue