expressjs.com icon indicating copy to clipboard operation
expressjs.com copied to clipboard

Missing documentation for wildcard parameters

Open jjspace opened this issue 10 months ago • 1 comments

Description

I am unable to find any documentation indicating how wildcard parameters work in v5. The only mention I've been able to find is in the v5 Migration guide which states:

The wildcard * must have a name, matching the behavior of parameters :, use /splat instead of /

The Routing docs do not explain how this syntax works. The closest it says there is that "the characters ?, +, *, [], and () are handled differently than in version 4, please review the migration guide for more information." which only states what I put above.

The section dedicated to Route Parameters on the same page also does not explain that you can swap out the : with * to consume more of the path.

The req.params section of the docs also doesn't indicate that you even can use * params. It also does not indicate that these params will be an array of strings that were split on /

Expectations

The path syntax documentation and any docs about routing and handling route parameters should indicate that wildcard parameters are an option and explain how they work and how someone should be using them.

jjspace avatar May 01 '25 22:05 jjspace

Would something like https://github.com/krzysdz/expressjs.com/commit/07dee6020c9e0b7ed1fe54b05dbe3a3a39f7173c be enough?

https://github.com/expressjs/expressjs.com/blob/07dee6020c9e0b7ed1fe54b05dbe3a3a39f7173c/en/guide/routing.md?plain=1#L244-L250

I think that maybe the "Route paths" and "Route parameters" sections should be somehow split into 4.x and 5.x versions, but I don't have a good idea on how to do it well.

krzysdz avatar Nov 02 '25 20:11 krzysdz