the claude code sourcemaps leaked march 31
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 38 lines 1.0 kB view raw
1/** 2 * Shared utilities for expanding environment variables in MCP server configurations 3 */ 4 5/** 6 * Expand environment variables in a string value 7 * Handles ${VAR} and ${VAR:-default} syntax 8 * @returns Object with expanded string and list of missing variables 9 */ 10export function expandEnvVarsInString(value: string): { 11 expanded: string 12 missingVars: string[] 13} { 14 const missingVars: string[] = [] 15 16 const expanded = value.replace(/\$\{([^}]+)\}/g, (match, varContent) => { 17 // Split on :- to support default values (limit to 2 parts to preserve :- in defaults) 18 const [varName, defaultValue] = varContent.split(':-', 2) 19 const envValue = process.env[varName] 20 21 if (envValue !== undefined) { 22 return envValue 23 } 24 if (defaultValue !== undefined) { 25 return defaultValue 26 } 27 28 // Track missing variable for error reporting 29 missingVars.push(varName) 30 // Return original if not found (allows debugging but will be reported as error) 31 return match 32 }) 33 34 return { 35 expanded, 36 missingVars, 37 } 38}