( template: string, variables: Record<string, string>, )
| 1 | const HTTP_VARIABLE_PATTERN = /\{\{\s*([\w.-]+)\s*\}\}/g |
| 2 | |
| 3 | export function interpolateHttpVariables( |
| 4 | template: string, |
| 5 | variables: Record<string, string>, |
| 6 | ): string { |
| 7 | return template.replace(HTTP_VARIABLE_PATTERN, (match, key: string) => { |
| 8 | return Object.prototype.hasOwnProperty.call(variables, key) |
| 9 | ? variables[key] |
| 10 | : match |
| 11 | }) |
| 12 | } |
no outgoing calls
no test coverage detected