From e4675af4dd8267a88bed50bf3d3f1aa323d17987 Mon Sep 17 00:00:00 2001 From: SwiftHawk Date: Thu, 16 May 2024 10:55:44 +0500 Subject: [PATCH] fix: handle the case when zip entry is undefined --- src/utils/zip.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/zip.ts b/src/utils/zip.ts index 1d6379a..71bc556 100644 --- a/src/utils/zip.ts +++ b/src/utils/zip.ts @@ -17,6 +17,11 @@ export const readContentOfZipEntry = async ( // Get the zip entry corresponding to the specified file path const zipEntry = zip.files[filePath] + if (!zipEntry) { + toast.error(`Couldn't find file in zip archive at ${filePath}`) + return null + } + // Read the content of the zip entry asynchronously const fileContent = await zipEntry.async(outputType).catch((err) => { // Handle any errors that occur during the read operation