From a77ad9446cbefefa7d46bc3dffe43dd6d4252615 Mon Sep 17 00:00:00 2001 From: isafulf <51974293+isafulf@users.noreply.github.com> Date: Sun, 2 Apr 2023 17:26:53 -0700 Subject: [PATCH] address https://github.com/openai/openai-cookbook/issues/159 --- .../nextjs-with-flask-server/client/src/services/utils.ts | 5 +++++ apps/file-q-and-a/nextjs/src/services/utils.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/apps/file-q-and-a/nextjs-with-flask-server/client/src/services/utils.ts b/apps/file-q-and-a/nextjs-with-flask-server/client/src/services/utils.ts index 9863f1b3..843a4865 100644 --- a/apps/file-q-and-a/nextjs-with-flask-server/client/src/services/utils.ts +++ b/apps/file-q-and-a/nextjs-with-flask-server/client/src/services/utils.ts @@ -1,6 +1,11 @@ // A function that takes a file name and a string and returns true if the file name is contained in the string // after removing punctuation and whitespace from both export const isFileNameInString = (fileName: string, str: string) => { + // Check if the input string is null or undefined + if (!str) { + return false; + } + // Convert both to lowercase and remove punctuation and whitespace const normalizedFileName = fileName .toLowerCase() diff --git a/apps/file-q-and-a/nextjs/src/services/utils.ts b/apps/file-q-and-a/nextjs/src/services/utils.ts index 9863f1b3..843a4865 100644 --- a/apps/file-q-and-a/nextjs/src/services/utils.ts +++ b/apps/file-q-and-a/nextjs/src/services/utils.ts @@ -1,6 +1,11 @@ // A function that takes a file name and a string and returns true if the file name is contained in the string // after removing punctuation and whitespace from both export const isFileNameInString = (fileName: string, str: string) => { + // Check if the input string is null or undefined + if (!str) { + return false; + } + // Convert both to lowercase and remove punctuation and whitespace const normalizedFileName = fileName .toLowerCase()