From cd2462eabe09a361e20189325dcbd53a0125c8b0 Mon Sep 17 00:00:00 2001 From: Ethan Doh Date: Wed, 31 May 2023 14:09:55 -0400 Subject: [PATCH] fix an issue with prop children containing characters that causes decodeURIComponent to throw an error --- src/parsers/scrapper.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/parsers/scrapper.js b/src/parsers/scrapper.js index d20ae2f8..be9293ba 100644 --- a/src/parsers/scrapper.js +++ b/src/parsers/scrapper.js @@ -16,8 +16,16 @@ import TermsScrapper from "../parsers/terms/scrapper"; * @param {array} termKeywords terms which needs to find/extract from content */ const scrapeFormats = (allowedFormats, content, termKeywords) => { + const _content = content.split(' ').map(seg => { + try { + decodeURIComponent(seg) + return seg + } catch (error) { + return encodeURIComponent(seg) + } + }).join(' ') const data = { - content: decodeURIComponent(content), + content: decodeURIComponent(_content), urls: [], images: [], emails: [],