From f4cf646f80341bb5df03a7519ab877de00070660 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 8 Mar 2021 22:06:18 -0500 Subject: [PATCH] Add checks for empty categories after filtering --- src/routes/getSkipSegments.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/routes/getSkipSegments.ts b/src/routes/getSkipSegments.ts index 54e74e2..65ab4f1 100644 --- a/src/routes/getSkipSegments.ts +++ b/src/routes/getSkipSegments.ts @@ -53,6 +53,7 @@ async function getSegmentsByVideoID(req: Request, videoID: string, categories: C try { categories = categories.filter((category) => !/[^a-z|_|-]/.test(category)); + if (categories.length === 0) return null; const segmentsByCategory: SBRecord = (await db .prepare( @@ -88,6 +89,7 @@ async function getSegmentsByHash(req: Request, hashedVideoIDPrefix: VideoIDHash, type SegmentWithHashPerVideoID = SBRecord}>; categories = categories.filter((category) => !(/[^a-z|_|-]/.test(category))); + if (categories.length === 0) return null; const segmentPerVideoID: SegmentWithHashPerVideoID = (await db .prepare(