question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

koa-router v9 not supporting wildcard anymore

See original GitHub issue

router.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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
tabarracommented, Jun 21, 2020

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)

0reactions
niftylettucecommented, Dec 22, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

koa-router v9 not supporting wildcard anymore? · Issue #527 - GitHub
I recently upgraded to koa-router v9 and I see wildcard routes are not supported anymore: router.all(['/', '/*'], ctx => send(ctx, 'index.html', ...
Read more >
koa-router - Bountysource
I recently upgraded to koa-router v9 and I see wildcard routes are not supported anymore: router.all(['/', '/*'], ctx => send(ctx, 'index.html', ...
Read more >
how to use Wildcards in koa-route - node.js - Stack Overflow
I've been using https://github.com/alexmingoia/koa-router. I found koa-route too limiting. It allows RegExp matching:
Read more >
Node.js Notes for Professionals
not a liated with o cial Node.js group(s) or company(s). ... Section 35.1: Node ES6 Support and creating a project with...
Read more >
Untitled
Casamento homoafetivo no parana, Telescope goldfish lost eye? ... Freddy hausser jukebox, Tripac heater not working, Centrecom fs716 switch, Euro inmedia ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found