From 9dc79aaca6ccdd1b4a809191741c7ddb1041fca0 Mon Sep 17 00:00:00 2001 From: Rongrong <15956627+Rongronggg9@users.noreply.github.com> Date: Tue, 22 Feb 2022 03:30:17 +0800 Subject: [PATCH] fix(route)(jike/user): improper linebreak (#9168) Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com> --- lib/routes/jike/user.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/routes/jike/user.js b/lib/routes/jike/user.js index a5470d9079..34e75a8e78 100644 --- a/lib/routes/jike/user.js +++ b/lib/routes/jike/user.js @@ -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, '
'); let shortenTitle = '一条动态'; if (content) { shortenTitle = content.length > 75 ? `${content.substr(0, 75)}...` : content; + shortenTitle = shortenTitle.replace(/(
)+/g, ' '); content = `${content}

`; } @@ -65,8 +67,8 @@ module.exports = async (ctx) => { repostImgTemplate += `
`; }); - const repostContent = `转发 ${screenNameTemplate}: ${item.target.content}${repostImgTemplate}`; - content = `${content}${repostContent}`.replace(/\n|\r/g, '
'); + const repostContent = `转发 ${screenNameTemplate}: ${item.target.content}${repostImgTemplate}`.replace(/\r\n|\n|\r/g, '
'); + 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(/(
|\s)+$/, ''), pubDate: new Date(item.createdAt).toUTCString(), link: linkMap[item.type], };