avoid 500s on slugify

pull/11421/merge^2
Alan 2023-09-21 22:55:37 -07:00
parent 4e7b8965d1
commit a55f002490
1 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,9 @@
// For eg:- "test-slug" is the slug user wants to set but while typing "test-" would get replace to "test" becauser of replace(/-+$/, "")
export const slugify = (str: string, forDisplayingInput?: boolean) => {
if (!str) {
return "";
}
const s = str
.toLowerCase() // Convert to lowercase
.trim() // Remove whitespace from both sides