Skip to content

Commit

Permalink
Merge branch 'DIYgod/master' into fix/hotfix-namespace-again
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL committed Dec 5, 2023
2 parents ad2e967 + 88241f5 commit ae182e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/middleware/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ module.exports = async (ctx, next) => {
});
}
} catch (err) {
if (err instanceof Error && !err.stack.split('\n')[0].includes('lib/middleware/parameter.js')) {
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.request.path;
}
Expand Down
2 changes: 1 addition & 1 deletion test/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function checkRSS(response) {
expect(date).toEqual(expect.any(String));
expect(Date.parse(date)).toEqual(expect.any(Number));
expect(new Date() - new Date(date)).toBeGreaterThan(-1000 * 60 * 60 * 24 * 5);
expect(new Date() - new Date(date)).toBeLessThan(1000 * 60 * 60 * 24 * 30 * 12 * 5);
expect(new Date() - new Date(date)).toBeLessThan(1000 * 60 * 60 * 24 * 30 * 12 * 10);
};

const parsed = await parser.parseString(response.text);
Expand Down

0 comments on commit ae182e1

Please sign in to comment.