Repository navigation
fix(cli): handle Windows drive letters in path URL validation - #282
Merged
dirac-run merged 1 commit intoNov 22, 2026
Merged
Conversation
Owner
|
Thanks for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where Windows paths with drive letters (such as
C:\...orD:\...) passed toopenExternalwere parsed as URLs with single-letter drive protocols (for examplec:), causingopenExternalto throw an unhandled exception:Blocked URL with disallowed scheme 'c:'. This prevented CLI diagnostic utilities likedirac dev logfrom opening logs and caused unhandled rejection failures on Windows environments.Fixes #121
Root Cause & Problem
In
src/utils/env.ts,openExternalvalidated target URLs by passing the target string directly tonew URL(url)and enforcingALLOWED_OPEN_SCHEMES = ["https:", "http:"].When Windows file paths or commands like
dirac dev logcalledopenExternal(getCliLogFilePath()):C:as a scheme protocol (parsed.protocol === "c:")."c:"was not inALLOWED_OPEN_SCHEMES,openExternalthrewError: Blocked URL with disallowed scheme 'c:'.onUnhandledException, disrupting normal event loop and input stream processing until user interaction occurs. On POSIX, raw file paths would also fail withTypeError: Invalid URL.Technical Solution
src/utils/env.ts:"file:"toALLOWED_OPEN_SCHEMES.normalizeOpenTarget(target: string): stringto detect Windows drive paths (C:\...,d:/...), UNC paths (\\...), and absolute filesystem paths, normalizing them to validfile://URLs usingpathToFileURL(target).href.javascript:,data:) and invalid URL strings.cli/src/utils/openExternal.test.ts:C:\...), forward-slash Windows paths (d:/...), directfile://URLs, disallowed scheme rejections (javascript:,data:), and invalid URLs.Test Plan
npx vitest run src/utils/openExternal.test.ts(13 tests passed)npx vitest run src/controllers/openExternal.test.ts(5 tests passed)npx vitest run src/utils/terminal-output.test.ts(3 tests passed)npx biome check src/utils/env.ts cli/src/utils/openExternal.test.ts(clean, 0 errors)npm run typecheck:cli(clean, 0 errors)npm run typecheck:root(clean, 0 errors)