summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/desktop/src/utils')
-rw-r--r--packages/desktop/src/utils/path.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/desktop/src/utils/path.ts b/packages/desktop/src/utils/path.ts
index 9c026ca41..3ae48cdb3 100644
--- a/packages/desktop/src/utils/path.ts
+++ b/packages/desktop/src/utils/path.ts
@@ -1,6 +1,8 @@
export function getFilename(path: string) {
- const parts = path.split("/")
- return parts[parts.length - 1]
+ if (!path) return ""
+ const trimmed = path.replace(/[\/]+$/, "")
+ const parts = trimmed.split("/")
+ return parts[parts.length - 1] ?? ""
}
export function getDirectory(path: string) {