From 0dd5b029d07d54a84d75790313dce0e4b0843736 Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Thu, 25 Apr 2024 09:18:48 +0530 Subject: [PATCH] Fix windows separator --- common/get-file-name.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/get-file-name.ts b/common/get-file-name.ts index 4a826f5..49e4b4f 100644 --- a/common/get-file-name.ts +++ b/common/get-file-name.ts @@ -1,8 +1,5 @@ -export default function getFilenameFromPath( - path: string, - withExtension: boolean = true, -) { +export default function getFilenameFromPath(path: string) { if (!path) return ""; - if (withExtension) return path.split("/").slice(-1)[0]; - return path.split("/").slice(-1)[0].split(".").slice(0, -1).join("."); + const separator = path.includes("/") ? "/" : "\\"; + return path.split(separator).slice(-1)[0]; }