Using * wildcard no longer works
See original GitHub issuenode.js version: 12.6.1
npm/yarn and version: npm 6.14.4
@koa/router
version: 9.0.0
koa
version: 2.11.0
Code sample:
const Koa = require('koa')
const Router = require('@koa/router')
const app = new Koa()
const router = new Router()
const port = 8000
router.get('*', (ctx) => {
ctx.body = 'hello'
})
app.use(router.routes())
app.listen(port, () => {
console.log(`listening on ${port}`)
})
Expected Behavior:
App should not crash
Actual Behavior:
App crashes:
/home/z/.tmp/1586900133/node_modules/path-to-regexp/dist/index.js:113
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
^
TypeError: Unexpected MODIFIER at 0, expected END
at mustConsume (/home/z/.tmp/1586900133/node_modules/path-to-regexp/dist/index.js:113:15)
at parse (/home/z/.tmp/1586900133/node_modules/path-to-regexp/dist/index.js:172:9)
at stringToRegexp (/home/z/.tmp/1586900133/node_modules/path-to-regexp/dist/index.js:329:27)
at pathToRegexp (/home/z/.tmp/1586900133/node_modules/path-to-regexp/dist/index.js:403:12)
at new Layer (/home/z/.tmp/1586900133/node_modules/@koa/router/lib/layer.js:48:17)
at Router.register (/home/z/.tmp/1586900133/node_modules/@koa/router/lib/router.js:578:15)
at Router.<computed> [as get] (/home/z/.tmp/1586900133/node_modules/@koa/router/lib/router.js:203:12)
at Object.<anonymous> (/home/z/.tmp/1586900133/index.js:8:8)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
I believe the path-to-regexp upgrade in #71 broke this. The use case here is, for example, SSR on any route that doesn’t match a previously defined one.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Sometimes asterisk wildcard does not work!
Hi, dear EXCEL pros: I've used asterisk wildcard in formula before and most of the time they worked perfectly well. But not in...
Read more >Excel wildcard not working - Stack Overflow
The way Excel implements the * wildcard is fundamentally wrong, in my opinion. The * should be any characters, including no characters.
Read more >Excel Wildcard IF - NOT WORKING! | If Cell Contains Text ...
Learn more. Switch camera ... Excel Wildcard IF - NOT WORKING ! ... You cannot use the wildcard characters *, ! in a...
Read more >Excel Wildcard Characters - Why Aren't You Using These?
There are three Excel wildcard characters (asterisk, question mark, and tilde) that can get some amazing stuff done in Excel. Here are some...
Read more >The asterisk (*) wildcard no longer works when defining URLs ...
Issue 371888: The asterisk (*) wildcard no longer works when defining URLs for whitelisting (using the Windows Group Policy Editor and chrome.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not a bug, it’s a feature :trollface:
For real though: it’s a breaking change inside
path-to-regexp
https://github.com/pillarjs/path-to-regexp#compatibility-with-express--4x
It is marked as a breaking change: which is why it’s
9.0.0
and not8.1.0
😎But yeah, probably a note in the readme to underline breaking changes in the path-to-regexp library with a link to it or something, why not.