export const substituteParameters = (text: string, params: Record): 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; };