fix: nga img and url (#2400)

This commit is contained in:
凉凉
2019-06-13 15:32:55 +08:00
committed by DIYgod
parent 60c2bb530d
commit 34e5869b2a
+8 -1
View File
@@ -2,6 +2,13 @@ const got = require('@/utils/got');
module.exports = async (ctx) => {
const { fid } = ctx.params;
const formatContent = (content) =>
content
.replace(/\[img\](.+?)\[\/img\]/g, (match, p1) => {
const src = p1.replace(/\?.*/g, '');
return `<img src="${src}" referrerpolicy="no-referrer" />`;
})
.replace(/\[url\](.+?)\[\/url\]/g, `<a href="$1">$1</a>`);
const homePage = await got({
method: 'post',
url: 'https://ngabbs.com/app_api.php?__lib=subject&__act=list',
@@ -39,7 +46,7 @@ module.exports = async (ctx) => {
},
});
return response.data.result[0].content;
return formatContent(response.data.result[0].content);
});
item.description = description;