mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 01:26:23 +00:00
Tighten URL slug validation (#6442)
* Tighten URL slug validation * slug sanitization in frontend
This commit is contained in:
@@ -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, '-')
|
||||
}
|
||||
Reference in New Issue
Block a user