From a55f00249038bd781cb515350fa3400a2e361605 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 21 Sep 2023 22:55:37 -0700 Subject: [PATCH] avoid 500s on slugify --- packages/lib/slugify.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/lib/slugify.ts b/packages/lib/slugify.ts index e43d8d57e3..3ace3c9d0e 100644 --- a/packages/lib/slugify.ts +++ b/packages/lib/slugify.ts @@ -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