MCPcopy Index your code
hub / github.com/codeaashu/claude-code / openInChrome

Function openInChrome

src/utils/claudeInChrome/common.ts:429–469  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

427}
428
429export async function openInChrome(url: string): Promise<boolean> {
430 const currentPlatform = getPlatform()
431
432 // Detect the best available browser
433 const browser = await detectAvailableBrowser()
434
435 if (!browser) {
436 logForDebugging('[Claude in Chrome] No compatible browser found')
437 return false
438 }
439
440 const config = CHROMIUM_BROWSERS[browser]
441
442 switch (currentPlatform) {
443 case 'macos': {
444 const { code } = await execFileNoThrow('open', [
445 '-a',
446 config.macos.appName,
447 url,
448 ])
449 return code === 0
450 }
451 case 'windows': {
452 // Use rundll32 to avoid cmd.exe metacharacter issues with URLs containing & | > <
453 const { code } = await execFileNoThrow('rundll32', ['url,OpenURL', url])
454 return code === 0
455 }
456 case 'wsl':
457 case 'linux': {
458 for (const binary of config.linux.binaries) {
459 const { code } = await execFileNoThrow(binary, [url])
460 if (code === 0) {
461 return true
462 }
463 }
464 return false
465 }
466 default:
467 return false
468 }
469}
470
471/**
472 * Get the socket directory path (Unix only)

Callers 2

ClaudeInChromeMenuFunction · 0.85

Calls 4

getPlatformFunction · 0.85
detectAvailableBrowserFunction · 0.85
logForDebuggingFunction · 0.85
execFileNoThrowFunction · 0.85

Tested by

no test coverage detected