From c85e0068094aec34a84bb6db2735da35b26304e2 Mon Sep 17 00:00:00 2001 From: Ir1dXD Date: Wed, 6 Jun 2018 23:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=20fix:=20use=20`[=E5=9B=BE=E7=89=87]`=20to=20r?= =?UTF-8?q?eplace=20=20(#278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: use `[图片]` to replace closes #267 * style: fix to remove warnings * remove unnecessary file --- routes/weibo/keyword.js | 2 +- routes/weibo/user.js | 2 +- routes/weibo/user2.js | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/routes/weibo/keyword.js b/routes/weibo/keyword.js index e9ece32d3..8591995c3 100644 --- a/routes/weibo/keyword.js +++ b/routes/weibo/keyword.js @@ -20,7 +20,7 @@ module.exports = async (ctx) => { link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`, description: `又有人在微博提到${keyword}了`, item: data.map((item) => { - const title = item.mblog.text.replace(/<.*?>/g, ''); + const title = item.mblog.text.replace(//g, '[图片]').replace(/<.*?>/g, ''); return { title: `${item.mblog.user.screen_name}: ${title.length > 24 ? title.slice(0, 24) + '...' : title}`, description: `${item.mblog.user.screen_name}: ${weiboUtils.format(item.mblog)}`, diff --git a/routes/weibo/user.js b/routes/weibo/user.js index 715158c9a..31108120a 100644 --- a/routes/weibo/user.js +++ b/routes/weibo/user.js @@ -30,7 +30,7 @@ module.exports = async (ctx) => { link: `http://weibo.com/${uid}/`, description: `${name}的微博`, item: response.data.data.cards.filter((item) => item.mblog && !item.mblog.isTop).map((item) => { - const title = item.mblog.text.replace(/<.*?>/g, ''); + const title = item.mblog.text.replace(//g, '[图片]').replace(/<.*?>/g, ''); return { title: title.length > 24 ? title.slice(0, 24) + '...' : title, description: weiboUtils.format(item.mblog), diff --git a/routes/weibo/user2.js b/routes/weibo/user2.js index 3e34bf357..916091788 100644 --- a/routes/weibo/user2.js +++ b/routes/weibo/user2.js @@ -27,9 +27,14 @@ module.exports = async (ctx) => { wb = {}; item = $(ele); titleEle = item.find('.wgtCell_txt'); - wb.title = titleEle.text().replace(/^\s+|\s+$/g, ''); + wb.title = titleEle + .text() + .replace(/^\s+|\s+$/g, '') + .replace(/\u200B/g, ''); if (wb.title.length > 24) { wb.title = wb.title.slice(0, 24) + '...'; + } else if (wb.title === '') { + wb.title = '[图片]'; } wb.description = titleEle .html()