mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: wrong path error
This commit is contained in:
@@ -3,6 +3,10 @@ const he = require('he');
|
||||
module.exports = async (ctx, next) => {
|
||||
await next();
|
||||
|
||||
if (!ctx._matchedRoute) {
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -127,3 +127,11 @@ describe('allow_empty', () => {
|
||||
expect(parsed.items.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('wrong_path', () => {
|
||||
it(`wrong_path`, async () => {
|
||||
const response = await request.get('/wrong');
|
||||
expect(response.status).toBe(404);
|
||||
expect(response.text).toMatch(/RSSHub 发生了一些意外: <pre>Error: wrong path/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user