MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / substituteEnvInValue

Function substituteEnvInValue

common/src/mcp/client.ts:25–34  ·  view source on GitHub ↗

* Substitutes environment variable references ($VAR_NAME) in a string with their values. * Supports both simple replacement ("$VAR_NAME") and interpolation ("Bearer $VAR_NAME").

(value: string)

Source from the content-addressed store, hash-verified

23 * Supports both simple replacement ("$VAR_NAME") and interpolation ("Bearer $VAR_NAME").
24 */
25function substituteEnvInValue(value: string): string {
26 return value.replace(/\$([A-Z_][A-Z0-9_]*)/g, (match, varName) => {
27 const envValue = process.env[varName]
28 if (envValue === undefined) {
29 // Return original if env var not found
30 return match
31 }
32 return envValue
33 })
34}
35
36/**
37 * Substitutes environment variable references in all values of a record.

Callers 1

substituteEnvInRecordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected