fix(route)(jike/user): improper linebreak (#9168)

Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
Rongrong
2022-02-22 03:30:17 +08:00
committed by GitHub
parent 0c7aaf8a5a
commit 9dc79aaca6
+5 -3
View File
@@ -49,10 +49,12 @@ module.exports = async (ctx) => {
});
let content = item.content || (item.linkInfo && item.linkInfo.title) || (item.question && item.question.title) || item.title || '';
content = content.replace(/\r\n|\n|\r/g, '<br>');
let shortenTitle = '一条动态';
if (content) {
shortenTitle = content.length > 75 ? `${content.substr(0, 75)}...` : content;
shortenTitle = shortenTitle.replace(/(<br>)+/g, ' ');
content = `${content}<br><br>`;
}
@@ -65,8 +67,8 @@ module.exports = async (ctx) => {
repostImgTemplate += `<br><img referrerpolicy="no-referrer" src="${item.thumbnailUrl}">`;
});
const repostContent = `转发 ${screenNameTemplate}: ${item.target.content}${repostImgTemplate}`;
content = `${content}${repostContent}`.replace(/\n|\r/g, '<br>');
const repostContent = `转发 ${screenNameTemplate}: ${item.target.content}${repostImgTemplate}`.replace(/\r\n|\n|\r/g, '<br>');
content = `${content}${repostContent}`;
}
// 部分功能未知
/* else if (item.type === 'ANSWER') {
@@ -101,7 +103,7 @@ module.exports = async (ctx) => {
const single = {
title: `${typeMap[item.type]}了: ${shortenTitle}`,
description: `${content}${linkTemplate}${imgTemplate}`,
description: `${content}${linkTemplate}${imgTemplate}`.replace(/(<br>|\s)+$/, ''),
pubDate: new Date(item.createdAt).toUTCString(),
link: linkMap[item.type],
};