The best way to control Claude Code, Codex and more from any computer or phone

main
ts 44 lines 1.71 KB
Raw
1 import * as NodePath from "@effect/platform-node-shared/NodePath"
2 import { assert, it } from "@effect/vitest"
3 import { assertNone, assertSome } from "@effect/vitest/utils"
4 import * as Effect from "effect/Effect"
5 import * as Path from "effect/Path"
6
7 it.layer(NodePath.layerPosix)("POSIX file URLs", (it) => {
8 it.effect("uses POSIX conversions", () =>
9 Effect.gen(function*() {
10 const path = yield* Path.Path
11
12 assert.strictEqual(yield* path.fromFileUrl(new URL("file:///tmp/file.txt")), "/tmp/file.txt")
13 assert.strictEqual((yield* path.toFileUrl("/tmp/file.txt")).href, "file:///tmp/file.txt")
14 }))
15 })
16
17 it.layer(NodePath.layerWin32)("Windows file URLs", (it) => {
18 it.effect("uses Windows conversions", () =>
19 Effect.gen(function*() {
20 const path = yield* Path.Path
21
22 assert.strictEqual(yield* path.fromFileUrl(new URL("file:///C:/Users/me/file.txt")), "C:\\Users\\me\\file.txt")
23 assert.strictEqual(
24 (yield* path.toFileUrl("C:\\Users\\me\\file.txt")).href,
25 "file:///C:/Users/me/file.txt"
26 )
27 }))
28 })
29
30 it.layer(NodePath.layerWin32)("Windows resolveWithin", (it) => {
31 it.effect("applies Windows root rules", () =>
32 Effect.gen(function*() {
33 const path = yield* Path.Path
34
35 assertSome(path.resolveWithin("C:\\srv", "a\\b.txt"), "C:\\srv\\a\\b.txt")
36 assertSome(path.resolveWithin("C:\\Srv", "..\\srv\\b.txt"), "C:\\srv\\b.txt")
37
38 assertNone(path.resolveWithin("C:\\srv", "..\\srv-other\\b.txt"))
39 assertNone(path.resolveWithin("C:\\srv", "C:b.txt"))
40 assertNone(path.resolveWithin("C:\\srv", "\\Windows"))
41 assertNone(path.resolveWithin("C:\\srv", "D:\\b.txt"))
42 assertNone(path.resolveWithin("C:\\srv", "\\\\server\\share\\b.txt"))
43 }))
44 })