mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
fix: retain allowEmpty in ctx.state (#2542)
* fix: retain allowEmpty in ctx.state See: https://github.com/koajs/koa/issues/1172 * fix: pass test case allow_empty * chore: get rid of eslint warning
This commit is contained in:
@@ -7,8 +7,8 @@ module.exports = async (ctx, next) => {
|
||||
throw Error('wrong path');
|
||||
}
|
||||
|
||||
if (ctx.state.data && (!ctx.state.data.item || ctx.state.data.item.length === 0) && !ctx.state.allowEmpty) {
|
||||
throw Error('this route is empty, please check the origin site or create an issue to feedback on https://github.com/DIYgod/RSSHub/issues/new/choose');
|
||||
if (ctx.state.data && (!ctx.state.data.item || ctx.state.data.item.length === 0) && !ctx.state.data.allowEmpty) {
|
||||
throw Error('this route is empty, please check the original site or create an issue on https://github.com/DIYgod/RSSHub/issues/new/choose');
|
||||
}
|
||||
|
||||
// decode HTML entities
|
||||
|
||||
@@ -48,6 +48,6 @@ module.exports = async (ctx) => {
|
||||
title,
|
||||
link,
|
||||
item,
|
||||
allowEmpty: true,
|
||||
};
|
||||
ctx.state.allowEmpty = true;
|
||||
};
|
||||
|
||||
@@ -12,8 +12,7 @@ module.exports = async (ctx) => {
|
||||
const data = $('script#shoebox-ember-data-store').html();
|
||||
const jsonObject = JSON.parse(data);
|
||||
const versions = jsonObject.data.attributes.versionHistory;
|
||||
let date;
|
||||
date = versions[0].releaseDate;
|
||||
const date = versions[0].releaseDate;
|
||||
|
||||
const titleTags = $('h1').attr('class', 'product-header__title');
|
||||
titleTags.find('span').remove();
|
||||
|
||||
@@ -37,6 +37,6 @@ module.exports = async (ctx) => {
|
||||
description: `${name} 直播间开播状态`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: liveItem,
|
||||
allowEmpty: true,
|
||||
};
|
||||
ctx.state.allowEmpty = true;
|
||||
};
|
||||
|
||||
@@ -31,5 +31,5 @@ module.exports = async (ctx) => {
|
||||
})
|
||||
.filter((item) => item),
|
||||
};
|
||||
ctx.state.allowEmpty = true;
|
||||
ctx.state.data.allowEmpty = true;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
];
|
||||
} else {
|
||||
ctx.state.allowEmpty = true;
|
||||
ctx.state.data.allowEmpty = true;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
||||
title: `${title} - Konachan Anime Wallpapers`,
|
||||
link: `${baseUrl}/post/popular_recent`,
|
||||
item: posts
|
||||
.filter((post) => !(safemode && post.rating != 's'))
|
||||
.filter((post) => !(safemode && post.rating !== 's'))
|
||||
.map((post) => {
|
||||
const content = (url) => {
|
||||
if (url.startsWith('//')) {
|
||||
|
||||
@@ -47,12 +47,12 @@ module.exports = async (ctx) => {
|
||||
|
||||
if (ctx.params.id === 'allow_empty') {
|
||||
item = null;
|
||||
ctx.state.allowEmpty = true;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Test ${ctx.params.id}`,
|
||||
link: 'https://github.com/DIYgod/RSSHub',
|
||||
item: item,
|
||||
item,
|
||||
allowEmpty: ctx.params.id === 'allow_empty',
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user