fix(route): javdb (#12818)

This commit is contained in:
Tony
2023-07-17 22:07:46 +08:00
committed by GitHub
parent 1c680ae5c3
commit 0a002d1b79
+5 -4
View File
@@ -7,7 +7,8 @@ const allowDomain = ['javdb.com', 'javdb36.com', 'javdb007.com'];
module.exports = {
ProcessItems: async (ctx, currentUrl, title) => {
const domain = ctx.query.domain ?? 'javdb.com';
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.includes(new URL(`https://${domain}/`).hostname)) {
const url = new URL(currentUrl, `https://${domain}`);
if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.includes(url.hostname)) {
ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
@@ -15,7 +16,7 @@ module.exports = {
const response = await got({
method: 'get',
url: `${rootUrl}${currentUrl}`,
url: url.href,
});
const $ = cheerio.load(response.data);
@@ -68,11 +69,11 @@ module.exports = {
);
const htmlTitle = $('title').text();
const subject = htmlTitle.indexOf('|') === -1 ? '' : htmlTitle.split('|')[0];
const subject = htmlTitle.includes('|') ? htmlTitle.split('|')[0] : '';
return {
title: subject === '' ? title : `${subject} - ${title}`,
link: `${rootUrl}${currentUrl}`,
link: url.href,
item: items,
};
},