From 520ffe3d19133e9edf21358e03ed1cb66f6259d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Wed, 30 Sep 2026 15:23:34 +0200 Subject: [PATCH] Name embeds dropped from Windows paths correctly --- src/lib/embeds.ts | 2 +- tests/unit/embeds.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/embeds.ts b/src/lib/embeds.ts index be60ce6e1..bf8d112a8 100644 --- a/src/lib/embeds.ts +++ b/src/lib/embeds.ts @@ -1,5 +1,5 @@ export function basename(path: string): string { - return path.split("/").pop() ?? path; + return path.split(/[\\/]/).pop() ?? path; } export function embedPreviewKind( diff --git a/tests/unit/embeds.test.ts b/tests/unit/embeds.test.ts index 4a82a3a8b..8f2f5942a 100644 --- a/tests/unit/embeds.test.ts +++ b/tests/unit/embeds.test.ts @@ -5,6 +5,7 @@ import { basename, embedPreviewKind } from "@app/lib/embeds"; describe("basename", () => { test.each([ ["/home/alice/cat.png", "cat.png"], + ["C:\\Users\\alice\\cat.png", "cat.png"], ["cat.png", "cat.png"], ])("of %j is %j", (path, expected) => { expect(basename(path)).toBe(expected);