Name embeds dropped from Windows paths correctly

This commit is contained in:
Rūdolfs Ošiņš
2026-10-01 18:20:24 +02:00
parent 7a6c88f847
commit 520ffe3d19
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
export function basename(path: string): string {
return path.split("/").pop() ?? path;
return path.split(/[\\/]/).pop() ?? path;
}
export function embedPreviewKind(
+1
View File
@@ -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);