Browse Source
On macOS, osascript's folder picker can return hostname-prefixed paths (e.g. "HOSTNAME/Users/...") for network-mounted volumes instead of absolute POSIX paths, causing directory validation to fail. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>handoff-20260429-1057
4 changed files with 118 additions and 7 deletions
@ -0,0 +1,49 @@ |
|||
import { describe, it, expect } from "vitest"; |
|||
import { normalizeSelectedPath } from "../route"; |
|||
|
|||
describe("normalizeSelectedPath", () => { |
|||
it("should strip hostname prefix on macOS", () => { |
|||
expect(normalizeSelectedPath("AT-ALGKG9VR/Users/guy/Desktop", "darwin")) |
|||
.toBe("/Users/guy/Desktop"); |
|||
}); |
|||
|
|||
it("should preserve absolute paths on macOS", () => { |
|||
expect(normalizeSelectedPath("/Users/guy/Desktop", "darwin")) |
|||
.toBe("/Users/guy/Desktop"); |
|||
}); |
|||
|
|||
it("should remove trailing slash", () => { |
|||
expect(normalizeSelectedPath("/Users/guy/Desktop/", "darwin")) |
|||
.toBe("/Users/guy/Desktop"); |
|||
}); |
|||
|
|||
it("should strip hostname and trailing slash", () => { |
|||
expect(normalizeSelectedPath("HOST/Users/guy/", "darwin")) |
|||
.toBe("/Users/guy"); |
|||
}); |
|||
|
|||
it("should strip hostname prefix on Linux", () => { |
|||
expect(normalizeSelectedPath("hostname/home/user", "linux")) |
|||
.toBe("/home/user"); |
|||
}); |
|||
|
|||
it("should not modify Windows drive paths", () => { |
|||
expect(normalizeSelectedPath("C:\\Users\\guy", "win32")) |
|||
.toBe("C:\\Users\\guy"); |
|||
}); |
|||
|
|||
it("should preserve Windows drive root", () => { |
|||
expect(normalizeSelectedPath("C:\\", "win32")) |
|||
.toBe("C:\\"); |
|||
}); |
|||
|
|||
it("should preserve Unix root /", () => { |
|||
expect(normalizeSelectedPath("/", "darwin")) |
|||
.toBe("/"); |
|||
}); |
|||
|
|||
it("should leave hostname-only (no slash) as-is", () => { |
|||
expect(normalizeSelectedPath("HOSTNAME", "darwin")) |
|||
.toBe("HOSTNAME"); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue