Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard Route Issue in Koa-Router v13 #533

Closed
Caringor opened this issue Dec 29, 2024 · 0 comments
Closed

Wildcard Route Issue in Koa-Router v13 #533

Caringor opened this issue Dec 29, 2024 · 0 comments

Comments

@Caringor
Copy link

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

  1. 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!' };
    });
    
  2. Start the server and send a request matching the route (e.g., /api/123/some/path/to/resource).

  3. 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

  1. Is this a bug introduced in v13, or was the behavior of wildcard parameters intentionally changed or removed?

  2. How can I achieve similar functionality (capturing all remaining path segments) in koa-router v13?

  3. If this is not supported in v13, is there an alternative approach or a recommended workaround?

Thank you for your assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant