Files
contact-front/src/lib/surveyUrl.ts

5 lines
330 B
TypeScript

// 문자열에 들어있는 [$SID], [$헤더명] 치환 토큰을 values에 있는 값으로 바꾼다.
// 값이 없는 토큰은 빈 문자열로 치환한다.
export const substituteVariables = (contents: string, values: Record<string, string>) =>
contents.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");