mirror of
https://github.com/zhigang1992/telert.git
synced 2026-01-12 08:24:41 +08:00
fix: handle null input in HTML escaping function to prevent errors
This commit is contained in:
@@ -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 ?? {})
|
||||
|
||||
Reference in New Issue
Block a user