diff --git a/lib/routes/nature/siteindex.ts b/lib/routes/nature/siteindex.ts index 99ec1d809..d927800dd 100644 --- a/lib/routes/nature/siteindex.ts +++ b/lib/routes/nature/siteindex.ts @@ -18,7 +18,7 @@ export const route: Route = { supportScihub: false, }, name: 'Journal List', - maintainers: ['TonyRL'], + maintainers: ['TonyRL', 'pseudoyu'], handler, }; @@ -40,19 +40,33 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(`nature:siteindex:${item.title}`, async () => { - const response = await got(item.link, { cookieJar }); - const $ = load(response.data); - - delete item.link; try { - item.id = $('.app-latest-issue-row__image img') - .attr('src') - .match(/.*\/journal\/(\d{5})/)[1]; - item.description = item.id; + const response = await got(item.link, { cookieJar }); + const $ = load(response.data); + + const imgSrc = $('.app-latest-issue-row__image img').attr('src'); + if (imgSrc) { + const match = imgSrc.match(/.*\/journal\/(\d{5})/); + if (match) { + const id = match[1]; + return { + title: item.title, + name: item.name, + id, + description: id, + }; + } + } + return { + title: item.title, + name: item.name, + }; } catch { - // + return { + title: item.title, + name: item.name, + }; } - return item; }) ) );