mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
fix: fuck some unstandard url (#2961)
This commit is contained in:
@@ -39,6 +39,7 @@ module.exports = async (ctx, next) => {
|
|||||||
if (item.description) {
|
if (item.description) {
|
||||||
const $ = cheerio.load(item.description);
|
const $ = cheerio.load(item.description);
|
||||||
let baseUrl = item.link || ctx.state.data.link;
|
let baseUrl = item.link || ctx.state.data.link;
|
||||||
|
|
||||||
if (baseUrl && !baseUrl.match(/^https?:\/\//)) {
|
if (baseUrl && !baseUrl.match(/^https?:\/\//)) {
|
||||||
if (baseUrl.match(/^\/\//)) {
|
if (baseUrl.match(/^\/\//)) {
|
||||||
baseUrl = 'http:' + baseUrl;
|
baseUrl = 'http:' + baseUrl;
|
||||||
@@ -54,7 +55,11 @@ module.exports = async (ctx, next) => {
|
|||||||
|
|
||||||
// absolute link
|
// absolute link
|
||||||
if (baseUrl) {
|
if (baseUrl) {
|
||||||
|
try {
|
||||||
$ele.attr('href', new URL($ele.attr('href'), baseUrl).href);
|
$ele.attr('href', new URL($ele.attr('href'), baseUrl).href);
|
||||||
|
} catch (e) {
|
||||||
|
// no-empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,7 +79,11 @@ module.exports = async (ctx, next) => {
|
|||||||
|
|
||||||
// absolute link
|
// absolute link
|
||||||
if (baseUrl) {
|
if (baseUrl) {
|
||||||
|
try {
|
||||||
$ele.attr('src', new URL($ele.attr('src'), baseUrl).href);
|
$ele.attr('src', new URL($ele.attr('src'), baseUrl).href);
|
||||||
|
} catch (e) {
|
||||||
|
// no-empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// referrerpolicy
|
// referrerpolicy
|
||||||
|
|||||||
Reference in New Issue
Block a user