From 4bef483546bf0f8d6bea1b3f46109efa72b18401 Mon Sep 17 00:00:00 2001 From: Weaver Goldman Date: Fri, 2 Aug 2024 15:40:47 -0400 Subject: [PATCH] Strip windows paths. --- src/main/event-handlers/filesystem.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/event-handlers/filesystem.ts b/src/main/event-handlers/filesystem.ts index e31be4d..6bcb6de 100644 --- a/src/main/event-handlers/filesystem.ts +++ b/src/main/event-handlers/filesystem.ts @@ -52,15 +52,15 @@ export const addFSEventHandlers = (ipcMain: IpcMain, getMainWindow: () => Browse isDirectory = stats.isDirectory() } - const relativePath = targetPath.replace(folderPath, '').replace(/^\//, '') + const relativePath = targetPath.replace(folderPath, '').replace(/^[\/\\]/, '') let relativePathNext = '' if (targetPathNext) { - relativePathNext = targetPathNext.replace(folderPath, '').replace(/^\//, '') + relativePathNext = targetPathNext.replace(folderPath, '').replace(/^[\/\\]/, '') } // Make sure the path is not the root folder - if (relativePath === '') return + if (relativePath === '' || relativePath.length === 0) return // Split the path by the separator const pathParts = relativePath.split(sep)