fix: fix replacing logic in #2796 (#2821)

This commit is contained in:
Kid
2019-08-11 01:12:42 +08:00
committed by DIYgod
parent b34d319980
commit a18b1dbfd9

View File

@@ -27,7 +27,8 @@ const ProcessFeed = ({ data = [] }, showAuthor = false) => {
}
};
const formatText = (text, br = '<br>') => text.replace(/https:\/\/t\.co(.*)/g, '').replace(/\n/g, br);
const replaceBreak = (text) => text.replace(/<br><br>|<br>/g, ' ');
const formatText = (text) => text.replace(/https:\/\/t\.co(.*)/g, '').replace(/\n/g, '<br>');
const formatVideo = (media) => {
let content = '';
const video = media.video_info.variants.reduce((video, item) => {
@@ -100,10 +101,10 @@ const ProcessFeed = ({ data = [] }, showAuthor = false) => {
}
return {
title: `${showAuthor ? item.user.name + ': ' : ''}${item.in_reply_to_screen_name ? 'Re ' : ''}${formatText(item.full_text, '')}`,
description: `${showAuthor ? `<img width="15px" referrerpolicy="no-referrer" src="${item.user.profile_image_url_https}"><strong>${item.user.name}:</strong><br><br>` : ''}${
item.in_reply_to_screen_name ? 'Re ' : ''
}${formatText(item.full_text)}${url}${img}${quote}`,
title: `${showAuthor ? item.user.name + ': ' : ''}${item.in_reply_to_screen_name ? 'Re ' : ''}${replaceBreak(item.full_text)}`,
description: `${showAuthor ? `<img width="15px" referrerpolicy="no-referrer" src="${item.user.profile_image_url_https}"><strong>${item.user.name}:</strong><br><br>` : ''}${item.in_reply_to_screen_name ? 'Re ' : ''}${
item.full_text
}${url}${img}${quote}`,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://twitter.com/${item.user.screen_name}/status/${item.id_str}`,
};