fix(router): accept Windows verbatim workspace paths (#1460)

This commit is contained in:
Pascal André
2026-04-16 19:17:32 +02:00
committed by GitHub
parent 98f9340cff
commit f516efcb1d
3 changed files with 99 additions and 15 deletions

View 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,
);
});