feat: restrict the allowed characters for slug

This commit is contained in:
DIYgod
2023-03-06 01:41:18 +00:00
parent 11fc759533
commit 8324beaa09
2 changed files with 10 additions and 1 deletions
@@ -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, {