Description
Environment
-
Package Name: koa-router
-
Version: v13.x (latest)
-
Node.js Version: v22.12.0
-
Operating System: macOS 14.4.1
Summary
After upgrading to koa-router v13 from v12, I encountered an issue with wildcard routes. Specifically, routes defined with *
(e.g., :proxyPath*
) no longer work as expected.
Steps to Reproduce
-
Define a route using a wildcard parameter in the router setup:
const Router = require('koa-router'); const router = new Router(); router.get(`/api/:token/:proxyPath*`, async (ctx) => { ctx.body = { message: 'Wildcard route works!' }; });
-
Start the server and send a request matching the route (e.g.,
/api/123/some/path/to/resource
). -
Observe the error when running the application:
TypeError: Missing parameter name at 49: https://git.new/pathToRegexpError
Expected Behavior
In koa-router v12 and earlier versions, the route defined with *
correctly captured the remaining path segments. The server processed the request without errors.
Actual Behavior
With koa-router v13, the application throws the following error when using a wildcard route:
TypeError: Missing parameter name at 49: https://git.new/pathToRegexpError
Additional Information
-
This behavior change does not seem to be documented in the release notes.
-
I’ve reviewed the migration guide but couldn’t find details regarding this specific change or deprecation of wildcard support.
Questions
-
Is this a bug introduced in v13, or was the behavior of wildcard parameters intentionally changed or removed?
-
How can I achieve similar functionality (capturing all remaining path segments) in koa-router v13?
-
If this is not supported in v13, is there an alternative approach or a recommended workaround?
Thank you for your assistance!