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

Function resolvePathPatternForSandbox

src/utils/sandbox/sandbox-adapter.ts:99–119  ·  view source on GitHub ↗
(
  pattern: string,
  source: SettingSource,
)

Source from the content-addressed store, hash-verified

97 * @param source The settings source this pattern came from (needed to resolve `/path` patterns)
98 */
99export function resolvePathPatternForSandbox(
100 pattern: string,
101 source: SettingSource,
102): string {
103 // Handle // prefix - absolute from root (CC-specific convention)
104 if (pattern.startsWith('//')) {
105 return pattern.slice(1) // "//.aws/**" → "/.aws/**"
106 }
107
108 // Handle / prefix - relative to settings file directory (CC-specific convention)
109 // Note: ~/path and relative paths are passed through for sandbox-runtime to handle
110 if (pattern.startsWith('/') && !pattern.startsWith('//')) {
111 const root = getSettingsRootPathForSource(source)
112 // Pattern like "/foo/**" becomes "${root}/foo/**"
113 return resolve(root, pattern.slice(1))
114 }
115
116 // Other patterns (~/path, ./path, path) pass through as-is
117 // sandbox-runtime's normalizePathForSandbox will handle them
118 return pattern
119}
120
121/**
122 * Resolve paths from sandbox.filesystem.* settings (allowWrite, denyWrite, etc).

Callers 1

Calls 2

resolveFunction · 0.50

Tested by

no test coverage detected