| 1 | import * as NodePath from "@effect/platform-node-shared/NodePath" |
| 2 | import { assert, it } from "@effect/vitest" |
| 3 | import * as Effect from "effect/Effect" |
| 4 | import * as Path from "effect/Path" |
| 5 | |
| 6 | it.layer(NodePath.layerPosix)("POSIX file URLs", (it) => { |
| 7 | it.effect("uses POSIX conversions", () => |
| 8 | Effect.gen(function*() { |
| 9 | const path = yield* Path.Path |
| 10 | |
| 11 | assert.strictEqual(yield* path.fromFileUrl(new URL("file:///tmp/file.txt")), "/tmp/file.txt") |
| 12 | assert.strictEqual((yield* path.toFileUrl("/tmp/file.txt")).href, "file:///tmp/file.txt") |
| 13 | })) |
| 14 | }) |
| 15 | |
| 16 | it.layer(NodePath.layerWin32)("Windows file URLs", (it) => { |
| 17 | it.effect("uses Windows conversions", () => |
| 18 | Effect.gen(function*() { |
| 19 | const path = yield* Path.Path |
| 20 | |
| 21 | assert.strictEqual(yield* path.fromFileUrl(new URL("file:///C:/Users/me/file.txt")), "C:\\Users\\me\\file.txt") |
| 22 | assert.strictEqual( |
| 23 | (yield* path.toFileUrl("C:\\Users\\me\\file.txt")).href, |
| 24 | "file:///C:/Users/me/file.txt" |
| 25 | ) |
| 26 | })) |
| 27 | }) |