mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +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');
|
throw Error('wrong path');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.state.data && (!ctx.state.data.item || ctx.state.data.item.length === 0) && !ctx.state.allowEmpty) {
|
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 origin site or create an issue to feedback on https://github.com/DIYgod/RSSHub/issues/new/choose');
|
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
|
// decode HTML entities
|
||||||
|
|||||||
@@ -48,6 +48,6 @@ module.exports = async (ctx) => {
|
|||||||
title,
|
title,
|
||||||
link,
|
link,
|
||||||
item,
|
item,
|
||||||
|
allowEmpty: true,
|
||||||
};
|
};
|
||||||
ctx.state.allowEmpty = true;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ module.exports = async (ctx) => {
|
|||||||
const data = $('script#shoebox-ember-data-store').html();
|
const data = $('script#shoebox-ember-data-store').html();
|
||||||
const jsonObject = JSON.parse(data);
|
const jsonObject = JSON.parse(data);
|
||||||
const versions = jsonObject.data.attributes.versionHistory;
|
const versions = jsonObject.data.attributes.versionHistory;
|
||||||
let date;
|
const date = versions[0].releaseDate;
|
||||||
date = versions[0].releaseDate;
|
|
||||||
|
|
||||||
const titleTags = $('h1').attr('class', 'product-header__title');
|
const titleTags = $('h1').attr('class', 'product-header__title');
|
||||||
titleTags.find('span').remove();
|
titleTags.find('span').remove();
|
||||||
|
|||||||
@@ -37,6 +37,6 @@ module.exports = async (ctx) => {
|
|||||||
description: `${name} 直播间开播状态`,
|
description: `${name} 直播间开播状态`,
|
||||||
lastBuildDate: new Date().toUTCString(),
|
lastBuildDate: new Date().toUTCString(),
|
||||||
item: liveItem,
|
item: liveItem,
|
||||||
|
allowEmpty: true,
|
||||||
};
|
};
|
||||||
ctx.state.allowEmpty = true;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ module.exports = async (ctx) => {
|
|||||||
})
|
})
|
||||||
.filter((item) => item),
|
.filter((item) => item),
|
||||||
};
|
};
|
||||||
ctx.state.allowEmpty = true;
|
ctx.state.data.allowEmpty = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
ctx.state.allowEmpty = true;
|
ctx.state.data.allowEmpty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
|||||||
title: `${title} - Konachan Anime Wallpapers`,
|
title: `${title} - Konachan Anime Wallpapers`,
|
||||||
link: `${baseUrl}/post/popular_recent`,
|
link: `${baseUrl}/post/popular_recent`,
|
||||||
item: posts
|
item: posts
|
||||||
.filter((post) => !(safemode && post.rating != 's'))
|
.filter((post) => !(safemode && post.rating !== 's'))
|
||||||
.map((post) => {
|
.map((post) => {
|
||||||
const content = (url) => {
|
const content = (url) => {
|
||||||
if (url.startsWith('//')) {
|
if (url.startsWith('//')) {
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
if (ctx.params.id === 'allow_empty') {
|
if (ctx.params.id === 'allow_empty') {
|
||||||
item = null;
|
item = null;
|
||||||
ctx.state.allowEmpty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: `Test ${ctx.params.id}`,
|
title: `Test ${ctx.params.id}`,
|
||||||
link: 'https://github.com/DIYgod/RSSHub',
|
link: 'https://github.com/DIYgod/RSSHub',
|
||||||
item: item,
|
item,
|
||||||
|
allowEmpty: ctx.params.id === 'allow_empty',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user