koa-router v9 not supporting wildcard anymore
See original GitHub issuerouter.get(‘/*’, async (ctx) => {
ctx.type = ‘html’;
ctx.body = fs.createReadStream(${__dirname}/../public/index.html
);
});
same issuse https://github.com/ZijianHe/koa-router/issues/527#issue-636445799 the error where happing like this:
/Users/zz/workspace/zBase/z-app/node_modules/path-to-regexp/dist/index.js:113 throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type); ^
TypeError: Unexpected MODIFIER at 1, expected END at mustConsume (/Users/zz/workspace/zBase/z-app/node_modules/path-to-regexp/src/index.ts:157:11) at parse (/Users/zz/workspace/zBase/z-app/node_modules/path-to-regexp/src/index.ts:228:5) at stringToRegexp (/Users/zz/workspace/zBase/z-app/node_modules/path-to-regexp/src/index.ts:494:25) at pathToRegexp (/Users/zz/workspace/zBase/z-app/node_modules/path-to-regexp/src/index.ts:616:10) at new Layer (/Users/zz/workspace/zBase/z-app/node_modules/@koa/router/lib/layer.js:44:17) at Router.register (/Users/zz/workspace/zBase/z-app/node_modules/@koa/router/lib/router.js:561:17) at Router.get (/Users/zz/workspace/zBase/z-app/node_modules/@koa/router/lib/router.js:199:12) at Object.<anonymous> (/Users/zz/workspace/zBase/z-app/src/router/index.js:42:8) at Module._compile (internal/modules/cjs/loader.js:1158:30) at Module._compile (/Users/zz/workspace/zBase/z-app/node_modules/pirates/lib/index.js:99:24) at Module._extensions…js (internal/modules/cjs/loader.js:1178:10)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
This is a major breaking change (1.x.x to 6.1.0), and it was badly documented.
You can solve this by replacing
*
with(.*)
.Keep in mind the code sample you provided is vulnerable. Don’t create a read stream to an user-provided file hahaha (eg
../../../../../etc/passwd%00
)As stated, I will accept a PR if you open one and ping me after. My email is niftylettuce@gmail.com as well if you want to ping by email when PR is done. If the PR is only a few minutes to open then you should have no problem, thank you.