avoid 500s on slugify
parent
4e7b8965d1
commit
a55f002490
|
@ -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(/-+$/, "")
|
// 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) => {
|
export const slugify = (str: string, forDisplayingInput?: boolean) => {
|
||||||
|
if (!str) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
const s = str
|
const s = str
|
||||||
.toLowerCase() // Convert to lowercase
|
.toLowerCase() // Convert to lowercase
|
||||||
.trim() // Remove whitespace from both sides
|
.trim() // Remove whitespace from both sides
|
||||||
|
|
Loading…
Reference in New Issue