Tighten URL slug validation (#6442)

* Tighten URL slug validation

* slug sanitization in frontend
This commit is contained in:
aecsocket
2026-06-19 13:52:24 +00:00
committed by GitHub
parent b3257a0614
commit d33f00d2b1
11 changed files with 153 additions and 23 deletions
+10
View File
@@ -0,0 +1,10 @@
const PROJECT_SLUG_UNSAFE_CHARS = /[^a-zA-Z0-9._-]/g
export function generateUrlSlug(value: string) {
return value
.trim()
.toLowerCase()
.replaceAll(' ', '-')
.replaceAll(PROJECT_SLUG_UNSAFE_CHARS, '')
.replaceAll(/--+/gm, '-')
}