mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
fix: url base
This commit is contained in:
@@ -38,6 +38,14 @@ module.exports = async (ctx, next) => {
|
||||
ctx.state.data.item.forEach((item) => {
|
||||
if (item.description) {
|
||||
const $ = cheerio.load(item.description);
|
||||
let baseUrl = item.link || ctx.state.data.link;
|
||||
if (!baseUrl.match(/^https?:\/\//)) {
|
||||
if (baseUrl.match(/^\/\//)) {
|
||||
baseUrl = 'http:' + baseUrl;
|
||||
} else {
|
||||
baseUrl = 'http://' + baseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
$('script').remove();
|
||||
|
||||
@@ -46,7 +54,7 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
// absolute link
|
||||
if (ctx.state.data.link) {
|
||||
$ele.attr('href', new URL($ele.attr('href'), item.link || ctx.state.data.link).href);
|
||||
$ele.attr('href', new URL($ele.attr('href'), baseUrl).href);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,7 +74,7 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
// absolute link
|
||||
if (ctx.state.data.link) {
|
||||
$ele.attr('src', new URL($ele.attr('src'), item.link || ctx.state.data.link).href);
|
||||
$ele.attr('src', new URL($ele.attr('src'), baseUrl).href);
|
||||
}
|
||||
|
||||
// referrerpolicy
|
||||
|
||||
Reference in New Issue
Block a user