Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route): javdb #12818

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(route): javdb
  • Loading branch information
TonyRL committed Jul 17, 2023
commit 8c453359da3866958b3824846d0ab42b39ab1cd3
9 changes: 5 additions & 4 deletions lib/v2/javdb/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ 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'.`);
}

const rootUrl = `https://${domain}`;

const response = await got({
method: 'get',
url: `${rootUrl}${currentUrl}`,
url: url.href,
});

const $ = cheerio.load(response.data);
Expand Down Expand Up @@ -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,
};
},
Expand Down