Skip to content

named catch-all routes ([...name]) don't match the base path #4808

Closed

Description

@pi0x

Follow-up of #1242 for v3.

A named catch-all route like routes/test/[...path].ts matches /test/a/b but not /test or /test/. The unnamed form routes/test/[...].ts does match /test, so the two behave differently.

File Route /test /test/a/b
routes/test/[...].ts /test/** matches matches
routes/test/[...path].ts /test/**:path no match matches (path: "a/b")

This is expected rou3 behavior: in rou3 1.0, **:name means one or more segments, while ** means zero or more. The difference comes from how src/scan.ts maps [...name] to **:name. The current workaround is adding routes/test/index.ts that re-exports the catch-all handler.

A possible fix is mapping [...name] to :name(.*) instead, which matches /test (no name), /test/ (name: "") and /test/a/b (name: "a/b"). This would change matching for existing apps, so it fits v3.

Triaged with AI assistance.

Activity

  1. added
    enhancement
    on Oct 17, 2026
  2. charan-rathore commented on Oct 17, 2026

    @charan-rathore

    Reproduced against rou3 1.0 directly: /test/:path matches /test/a/b but neither /test nor /test/, while /test/ matches all three - so the v3 regression from #1242 is exactly the one-or-more vs zero-or-more split you describe.

    Fix direction: in src/scan.ts map the named catch-all [...name] to the zero-or-more named form :name(.) instead of **:name. Verified locally that /test/:path(.) matches /test (no param), /test/ (path ""), and /test/a/b (path "a/b"), so handlers see the same shape as the unnamed form.

    I'd like to take this one - ok to open the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions