mirror of
https://github.com/different-ai/openwork
synced 2026-04-26 01:25:10 +02:00
fix(router): accept Windows verbatim workspace paths (#1460)
This commit is contained in:
49
apps/opencode-router/test/path-scope.test.js
Normal file
49
apps/opencode-router/test/path-scope.test.js
Normal file
@@ -0,0 +1,49 @@
|
||||
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,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user