mirror of
https://github.com/different-ai/openwork
synced 2026-04-26 01:25:10 +02:00
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
isWithinWorkspaceRootPath,
|
|
normalizeScopedDirectoryPath,
|
|
} from "../dist/path-scope.js";
|
|
|
|
test("normalizeScopedDirectoryPath strips Windows verbatim prefixes", () => {
|
|
const workspaceRoot = String.raw`G:\project\openwork_project`;
|
|
const candidate = String.raw`\\?\G:\project\openwork_project`;
|
|
|
|
assert.equal(
|
|
normalizeScopedDirectoryPath(workspaceRoot, "win32"),
|
|
"g:/project/openwork_project",
|
|
);
|
|
assert.equal(
|
|
normalizeScopedDirectoryPath(candidate, "win32"),
|
|
"g:/project/openwork_project",
|
|
);
|
|
});
|
|
|
|
test("isWithinWorkspaceRootPath accepts Windows verbatim aliases for workspace root", () => {
|
|
const workspaceRoot = String.raw`G:\project\openwork_project`;
|
|
const candidate = String.raw`\\?\G:\project\openwork_project`;
|
|
|
|
assert.equal(
|
|
isWithinWorkspaceRootPath({
|
|
workspaceRoot,
|
|
candidate,
|
|
platform: "win32",
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("isWithinWorkspaceRootPath still rejects directories outside the workspace root", () => {
|
|
const workspaceRoot = String.raw`G:\project\openwork_project`;
|
|
const candidate = String.raw`\\?\G:\project\outside`;
|
|
|
|
assert.equal(
|
|
isWithinWorkspaceRootPath({
|
|
workspaceRoot,
|
|
candidate,
|
|
platform: "win32",
|
|
}),
|
|
false,
|
|
);
|
|
});
|