diff --git a/src/message.ts b/src/message.ts index 28000e3..c3d6dc0 100644 --- a/src/message.ts +++ b/src/message.ts @@ -10,7 +10,7 @@ export type RichMessage = { // https://www.30secondsofcode.org/js/s/escape-unescape-html/ const escapeHTML = (str: string) => - str.replace( + str?.replace( /[&<>'"]/g, (tag: string) => ({ @@ -20,7 +20,7 @@ const escapeHTML = (str: string) => "'": ''', '"': '"' }[tag] || tag) - ); + ) ?? ""; export function formatRichMessage(message: RichMessage): string { const metadata = Object.entries(message.metadata ?? {})