From 13a51a5648742d944ca5055d4735d5ab116e6fe8 Mon Sep 17 00:00:00 2001 From: Deepak Prabhakara Date: Tue, 5 Mar 2024 19:06:09 +0000 Subject: [PATCH] handle undefined param in escapeHtml (#549) --- lib/post.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/post.ts b/lib/post.ts index 9af5444..827645b 100644 --- a/lib/post.ts +++ b/lib/post.ts @@ -1,10 +1,12 @@ const escapeHtml = (unsafeHtml: string) => { return unsafeHtml - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); + ? unsafeHtml + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + : unsafeHtml; }; const createPostForm = (postUrl: string, params: { name: string; value: string }[]) => {