修复 OSChina 可能采集到相对链接的问题 (#1986)

This commit is contained in:
zengxs 2019-04-25 14:33:53 +08:00 committed by DIYgod
parent 5de618fc88
commit da8fbb6744
1 changed files with 2 additions and 1 deletions

View File

@ -1,3 +1,4 @@
const url = require('url');
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
@ -58,7 +59,7 @@ module.exports = async (ctx) => {
const item = {
title: each.find('a', 'h3').attr('title'),
description: each.find('p', '.description').text(),
link: encodeURI(originalUrl),
link: url.resolve('https://www.oschina.net', encodeURI(originalUrl)),
};
if (/^https?:\/\/www.oschina.net\/news\/.*$/.test(originalUrl)) {
const key = 'oschina' + item.link;