fix(web): open workspace root links in the file explorer (#12449)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Alex Southwellandgithub-actions[bot] authored and GitHub committed 2026-09-29 21:05:44 -03:00
1 parent 916ec94f93
commit 55ec55b1fb
10 files changed
+83 -3

No files matched your search

@@ -155,6 +155,11 @@ describe("fileBasename", () => {
describe("workspaceRelativeFilePath", () => {
it.each([
["/repo/project", "/repo/project", "."],
["/repo/project/", "/repo/project/", "."],
["/", "/", "."],
["C:/USERS/mike/project", "c:/users/MIKE/project", "."],
["C:/", "c:/", "."],
["/repo/project/src/main.ts", "/repo/project", "src/main.ts"],
["/repo/project/src/main.ts", "/repo/project/", "src/main.ts"],
["C:\\Users\\mike\\t3code\\apps\\web\\a.ts", "C:/Users/mike/t3code", "apps/web/a.ts"],
@@ -340,6 +340,7 @@ export function workspaceRelativeFilePath(
const caseInsensitive = isWindowsAbsolutePath(stripSlashPrefixedWindowsDrive(workspaceRoot));
const pathForCompare = caseInsensitive ? normalizedPath.toLowerCase() : normalizedPath;
const rootForCompare = caseInsensitive ? normalizedRoot.toLowerCase() : normalizedRoot;
if (pathForCompare.replace(/\/+$/, "") === rootForCompare) return ".";
if (!pathForCompare.startsWith(`${rootForCompare}/`)) return null;
return normalizedPath.slice(normalizedRoot.length + 1);
}