Skip to content

Commit

Permalink
fix: use [图片] to replace <img> (DIYgod#278)
Browse files Browse the repository at this point in the history
* fix: use `[图片]` to replace <img>

closes DIYgod#267

* style: fix to remove warnings

* remove unnecessary file
  • Loading branch information
Ir1d authored and DIYgod committed Jun 6, 2018
1 parent 8b7fd4a commit c85e006
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion routes/weibo/keyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<img.*?>/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)}`,
Expand Down
2 changes: 1 addition & 1 deletion routes/weibo/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<img.*?>/g, '[图片]').replace(/<.*?>/g, '');
return {
title: title.length > 24 ? title.slice(0, 24) + '...' : title,
description: weiboUtils.format(item.mblog),
Expand Down
7 changes: 6 additions & 1 deletion routes/weibo/user2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c85e006

Please sign in to comment.