From f334814fb2b03708d70f09d7c208854efa06be93 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 30 Sep 2024 19:48:43 +0530 Subject: [PATCH] update findSlug logic to use fallback --- src/Common/hooks/useSlug.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Common/hooks/useSlug.ts b/src/Common/hooks/useSlug.ts index 78d2a567e37..a92407e73e5 100644 --- a/src/Common/hooks/useSlug.ts +++ b/src/Common/hooks/useSlug.ts @@ -31,6 +31,9 @@ export const useSlugs = (...prefix: string[]) => { const findSlug = (segments: string[], prefix: string, fallback?: string) => { const index = segments.findIndex((segment) => segment === prefix); if (index === -1) { + if (fallback) { + return fallback; + } throw new Error( `Prefix "${prefix}" not found in path "${segments.join("/")}"`, );