mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Name embeds dropped from Windows paths correctly
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
export function basename(path: string): string {
|
||||
return path.split("/").pop() ?? path;
|
||||
return path.split(/[\\/]/).pop() ?? path;
|
||||
}
|
||||
|
||||
export function embedPreviewKind(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user