Skip to content

Commit 75e76ee

Browse files
committed
fix: slugify remove non-alphanumeric characters
1 parent 22cdb34 commit 75e76ee

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/runtime/utils/text.ts

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export const slugify = (text: string) => {
152152
.normalize('NFKD') // The normalize() using NFKD method returns the Unicode Normalization Form of a given string.
153153
.toLowerCase() // Convert the string to lowercase letters
154154
.trim() // Remove whitespace from both sides of a string (optional)
155+
.replace(/[^a-z0-9\s_]/g, '') // Remove characters that are NOT alphanumeric (a-z, 0-9), whitespace, or underscores
155156
.replace(/\s+/g, '-') // Replace spaces with -
156157
.replace(/_/g, '-') // Replace _ with -
157158
.replace(/-{2,}/g, '-') // Replace multiple - with single -

0 commit comments

Comments
 (0)