fix(core): normalize workspace dir paths to file:// URIs#11561
fix(core): normalize workspace dir paths to file:// URIs#11561BillionClaw wants to merge 1 commit intocontinuedev:mainfrom
Conversation
Fixes continuedev#11559 When IDE extensions (e.g., IntelliJ on Linux) return workspace directories as plain file paths like '/home/user/project' instead of proper file:// URIs, the path resolution logic would produce incorrect double-prefixed paths like '/home/user/home/user/project'. This change adds a normalizeDirUri() helper that converts plain file paths to proper file:// URIs before joining with relative paths. - Added normalizeDirUri() to handle Linux, Windows, and already-URI paths - Updated resolveRelativePathInDir() and inferResolvedUriFromRelativePath() - Added tests for the normalization and both resolution functions
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/util/ideUtils.ts">
<violation number="1" location="core/util/ideUtils.ts:31">
P2: UNC Windows workspace paths are not normalized to `file://` URIs, so network-share directories can still bypass the new fix and break relative-path URI resolution.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| } | ||
|
|
||
| // For Windows paths (C:\ or drive letters) | ||
| if (/^[a-zA-Z]:/.test(dirPath)) { |
There was a problem hiding this comment.
P2: UNC Windows workspace paths are not normalized to file:// URIs, so network-share directories can still bypass the new fix and break relative-path URI resolution.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At core/util/ideUtils.ts, line 31:
<comment>UNC Windows workspace paths are not normalized to `file://` URIs, so network-share directories can still bypass the new fix and break relative-path URI resolution.</comment>
<file context>
@@ -6,6 +6,36 @@ import {
+ }
+
+ // For Windows paths (C:\ or drive letters)
+ if (/^[a-zA-Z]:/.test(dirPath)) {
+ const normalized = dirPath.replaceAll("\\", "/");
+ return `file:///${pathToUriPathSegment(normalized)}`;
</file context>
Description
Fixes #11559 - File Path Resolution Failure in Tools
When IDE extensions (e.g., IntelliJ on Linux) return workspace directories as plain file paths like
/home/user/projectinstead of proper file:// URIs, the path resolution logic would produce incorrect double-prefixed paths like/home/user/home/user/project.Root Cause
The
resolveRelativePathInDir()andinferResolvedUriFromRelativePath()functions incore/util/ideUtils.tsexpected workspace directories to always be in URI format (file:///home/user/project), but some IDE extensions return plain filesystem paths.Fix
Added
normalizeDirUri()helper that converts plain file paths to proper file:// URIs before joining with relative paths:/home/user/project)C:\\Users\\project)Tests
Added
core/util/ideUtils.vitest.tswith tests for:normalizeDirUri()- URI passthrough, Linux paths, Windows paths, encodingresolveRelativePathInDir()- normal case, bug case, regression guardinferResolvedUriFromRelativePath()- normal case, bug case, regression guardChecklist
Summary by cubic
Normalize workspace directory paths to file:// URIs to fix path resolution when IDEs return plain paths (e.g., IntelliJ on Linux). Prevents double-prefixed paths and ensures correct URI joining.
Written for commit da335b8. Summary will update on new commits.