5ba5b9899d
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
12 lines
440 B
TypeScript
12 lines
440 B
TypeScript
export const substituteParameters = (text: string, params: Record<string, string>): string => {
|
|
let substitutedText = text;
|
|
|
|
for (const key in params) {
|
|
// Escape special characters in the key (parameter) and match optional whitespace
|
|
const regex = new RegExp(`{{\\s*${key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*}}`, 'g');
|
|
substitutedText = substitutedText.replace(regex, params[key]);
|
|
}
|
|
|
|
return substitutedText;
|
|
};
|