From 961e0428e78769225c77cc01928b3466adab5377 Mon Sep 17 00:00:00 2001 From: Francisco Madeira Date: Mon, 8 Jan 2024 18:22:02 +0000 Subject: [PATCH] fix: Check for null on `makeReplacements` --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 49317df..a3ed7d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -461,7 +461,7 @@ export class I18n { /** * Make the place-holder replacements on a line. */ - makeReplacements(message: string, replacements?: ReplacementsInterface): string { + makeReplacements(message?: string, replacements?: ReplacementsInterface): string { const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1) Object.entries(replacements || []) @@ -469,7 +469,7 @@ export class I18n { .forEach(([key, value]) => { value = value.toString() - message = message + message = (message || '') .replace(new RegExp(`:${key}`, 'g'), value) .replace(new RegExp(`:${key.toUpperCase()}`, 'g'), value.toUpperCase()) .replace(new RegExp(`:${capitalize(key)}`, 'g'), capitalize(value))