From 3c3ee2fc88c89a3f1829331d57796a7558fc544a Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:40:51 +0700 Subject: [PATCH] fixed note content parser --- src/components/note/content/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/note/content/index.tsx b/src/components/note/content/index.tsx index 3e1f700e..8742ffd9 100644 --- a/src/components/note/content/index.tsx +++ b/src/components/note/content/index.tsx @@ -9,8 +9,11 @@ import reactStringReplace from 'react-string-replace'; export const Content = memo(function Content({ data }: { data: any }) { const content = useMemo(() => { let parsedContent; + let tags; // get data tags - const tags = data.tags ? JSON.parse(data.tags) : null; + if (data.tags.length > 1) { + tags = JSON.parse(data.tags); + } // remove all image urls parsedContent = data.content.replace(/(https?:\/\/.*\.(jpg|jpeg|gif|png|webp|mp4|webm)((\?.*)$|$))/gim, ''); // handle urls @@ -26,7 +29,7 @@ export const Content = memo(function Content({ data }: { data: any }) { )); // handle mentions - if (tags) { + if (tags.length > 0) { parsedContent = reactStringReplace(parsedContent, /\#\[(\d+)\]/gm, (match, i) => { if (tags[match][0] === 'p') { return ;