From ffef6e1dde57573a23dfab614d27ab656eee104e Mon Sep 17 00:00:00 2001 From: notofoe <43095406+notofoe@users.noreply.github.com> Date: Sat, 8 Aug 2020 17:12:13 +0800 Subject: [PATCH] feat: mastodon remove html tags for title --- lib/routes/mastodon/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/routes/mastodon/utils.js b/lib/routes/mastodon/utils.js index 475d9f49d..9f45fee57 100644 --- a/lib/routes/mastodon/utils.js +++ b/lib/routes/mastodon/utils.js @@ -3,6 +3,7 @@ const got = require('@/utils/got'); const parseStatuses = (data) => data.map((item) => { const content = item.content ? item.content.replace(/|<\/span.*?>/gm, '') : ''; + const contentRemovedHtml = content.replace(/<(?:.|\n)*?>/gm, '\n'); const mediaParse = (media_attachments) => media_attachments @@ -32,7 +33,7 @@ const parseStatuses = (data) => titleAuthor = `@${item.account.username}`; media = mediaParse(item.media_attachments); } - const titleText = item.sentitive === true ? `(CW) ${item.spoiler_text}` : content; + const titleText = item.sentitive === true ? `(CW) ${item.spoiler_text}` : contentRemovedHtml; return { title: `${titleAuthor}: "${titleText}"`,