Skip to content

Commit d73686e

Browse files
committed
fix(shared): preserve mixed UNC path compatibility
1 parent b23d0f5 commit d73686e

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/shared/src/path.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ describe("workspaceRelativeFilePath", () => {
118118
["/C:/Repo/src/main.ts", "c:\\repo", "src/main.ts"],
119119
["C:\\Repo\\src\\main.ts", "/c:/repo", "src/main.ts"],
120120
["\\\\SERVER\\Share\\Repo\\src\\main.ts", "\\\\server\\share\\repo", "src/main.ts"],
121+
["\\\\SERVER\\Share\\Repo\\src\\main.ts", "//server/share/repo", "src/main.ts"],
122+
["//server/share/a\\b.txt", "//server/share", "a\\b.txt"],
121123
["\\\\server\\share\\repo\\..\\notes.md", "\\\\server\\share\\repo", null],
122124
])("relates %s to %s", (path, workspaceRoot, relativePath) => {
123125
expect(workspaceRelativeFilePath(path, workspaceRoot)).toBe(relativePath);

‎packages/shared/src/path.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export function workspaceRelativeFilePath(
9595
workspaceRoot: string | null | undefined,
9696
): string | null {
9797
if (!workspaceRoot) return null;
98-
const caseInsensitive = isWindowsAbsolutePath(stripSlashPrefixedWindowsDrive(workspaceRoot));
98+
const caseInsensitive =
99+
isWindowsAbsolutePath(stripSlashPrefixedWindowsDrive(workspaceRoot)) ||
100+
(isNetworkPath(workspaceRoot) && isUncPath(path));
99101
const normalizedPath = caseInsensitive
100102
? stripSlashPrefixedWindowsDrive(path.replaceAll("\\", "/"))
101103
: path;

0 commit comments

Comments
 (0)