fix: nga img and url (#2400)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user