From 6afffbcb8b8db76e862afa6d348bdbc86f24e1cd Mon Sep 17 00:00:00 2001 From: Nya Candy Date: Mon, 5 Jun 2023 00:58:45 +0800 Subject: [PATCH] feat: change slug's invalid char to hyphen (#601) --- src/app/dashboard/[subdomain]/editor/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/dashboard/[subdomain]/editor/page.tsx b/src/app/dashboard/[subdomain]/editor/page.tsx index 9ba368c4..1a3535ba 100644 --- a/src/app/dashboard/[subdomain]/editor/page.tsx +++ b/src/app/dashboard/[subdomain]/editor/page.tsx @@ -181,12 +181,13 @@ export default function SubdomainEditor() { ) } if (key === "slug" && !/^[a-zA-Z0-9\-_]*$/.test(value as string)) { + // Replace all invalid chars + ;(value as string) = (value as string).replace(/[^\w\-]/g, "-") toast.error( t( "Slug can only contain letters, numbers, hyphens, and underscores.", ), ) - return } const newValues = { ...values, [key]: value } if (draftKey) {