* 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)
| 23 | * Supports both simple replacement ("$VAR_NAME") and interpolation ("Bearer $VAR_NAME"). |
| 24 | */ |
| 25 | function 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. |
no outgoing calls
no test coverage detected