From 7997c3137acb3fd885dc0e2875ad097880a54cae Mon Sep 17 00:00:00 2001 From: Youth Date: Thu, 11 May 2023 09:23:15 +0800 Subject: [PATCH] * refactor(getCitations.js): add null check for adaptiveCards variable before accessing its properties (#232) --- api/lib/parse/getCitations.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/lib/parse/getCitations.js b/api/lib/parse/getCitations.js index f4086a4e9e..0e36de695e 100644 --- a/api/lib/parse/getCitations.js +++ b/api/lib/parse/getCitations.js @@ -2,7 +2,8 @@ const regex = / \[.*?]\(.*?\)/g; const getCitations = (res) => { - const textBlocks = res.details.adaptiveCards[0].body; + const adaptiveCards = res.details.adaptiveCards; + const textBlocks = adaptiveCards && adaptiveCards[0].body; if (!textBlocks) return ''; let links = textBlocks[textBlocks.length - 1]?.text.match(regex); if (links?.length === 0 || !links) return '';