mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(core): duplicated path if the error is thrown from parameter (#13967)
* fix(core): double namespace if the error is thrown from parameter * test: fix test case
This commit is contained in:
@@ -39,9 +39,13 @@ module.exports = async (ctx, next) => {
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
// Append v2 route path
|
||||
ctx.request.path = (ctx.mountPath ?? '') + ctx.request.path;
|
||||
ctx._matchedRoute = ctx._matchedRoute ? (ctx.mountPath ?? '') + ctx._matchedRoute : ctx.request.path;
|
||||
if (err instanceof Error && !err.stack.split('\n')[1].includes('lib/middleware/parameter.js')) {
|
||||
// Append v2 route path if a route throws an error
|
||||
// since koa-mount will remove the mount path from ctx.request.path
|
||||
// https://github.com/koajs/mount/issues/62
|
||||
ctx.request.path = (ctx.mountPath ?? '') + ctx.request.path;
|
||||
ctx._matchedRoute = ctx._matchedRoute ? (ctx.mountPath ?? '') + ctx._matchedRoute : ctx._matchedRoute;
|
||||
}
|
||||
|
||||
let message = err;
|
||||
if (err.name && (err.name === 'HTTPError' || err.name === 'RequestError')) {
|
||||
|
||||
Reference in New Issue
Block a user