mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
fix(route/twitter): media t.co links not purged (#12864)
This commit is contained in:
+10
-4
@@ -29,10 +29,16 @@ const getOriginalImg = (url) => {
|
||||
};
|
||||
const replaceBreak = (text) => text.replace(/<br><br>|<br>/g, ' ');
|
||||
|
||||
const formatText = (text, urls) => {
|
||||
const formatText = (item) => {
|
||||
let text = item.full_text;
|
||||
const urls = item.entities.urls || [];
|
||||
urls.forEach((url) => {
|
||||
text = text.replaceAll(url.url, url.expanded_url);
|
||||
});
|
||||
const media = item.extended_entities?.media || [];
|
||||
media.forEach((m) => {
|
||||
text = text.replaceAll(m.url, '');
|
||||
});
|
||||
return text.trim().replace(/\n/g, '<br>');
|
||||
};
|
||||
|
||||
@@ -179,7 +185,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
||||
const originalItem = item;
|
||||
item = item.retweeted_status || item;
|
||||
item.full_text = item.full_text || item.text;
|
||||
item.full_text = formatText(item.full_text, item.entities.urls);
|
||||
item.full_text = formatText(item);
|
||||
const img = formatMedia(item);
|
||||
let picsPrefix = generatePicsPrefix(item);
|
||||
let quote = '';
|
||||
@@ -223,7 +229,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
||||
}
|
||||
|
||||
quote += `: `;
|
||||
quote += formatText(quoteData.full_text, quoteData.entities.urls);
|
||||
quote += formatText(quoteData);
|
||||
|
||||
if (!readable) {
|
||||
quote += '<br>';
|
||||
@@ -231,7 +237,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
||||
quote += formatMedia(quoteData);
|
||||
picsPrefix += generatePicsPrefix(quoteData);
|
||||
quoteInTitle += showEmojiForRetweetAndReply ? ' 💬 ' : showSymbolForRetweetAndReply ? ' RT ' : '';
|
||||
quoteInTitle += `${author.name}: ${formatText(quoteData.full_text, quoteData.entities.urls)}`;
|
||||
quoteInTitle += `${author.name}: ${formatText(quoteData)}`;
|
||||
|
||||
if (readable) {
|
||||
quote += `<br><small>Link: <a href='https://twitter.com/${author.screen_name}/status/${quoteData.id_str}' target='_blank' rel='noopener noreferrer'>https://twitter.com/${author.screen_name}/status/${quoteData.id_str}</a></small>`;
|
||||
|
||||
Reference in New Issue
Block a user