-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Description
When 4.x documentation was created the docs were copied from 3.x. One of the breaking changes was making req.params an object. This was partially corrected in #134, but the documentation still claims that if a regular expression is used, req.params is an array:
| When you use a regular expression for the route definition, capture groups are provided in the array using `req.params[n]`, where `n` is the n<sup>th</sup> capture group. This rule is applied to unnamed wild card matches with string routes such as `/file/*`: |
This isn't a huge problem, since values captured by unnamed capture groups have keys '0', '1', '2' etc. and req.params[n] access (where n is an integer), due to how JS works, will work. EDIT: In practice V8 optimizes array-indexed property access, so I won't mention this in my PR.
This error is present both in 4.x and 5.x docs (and DefinitelyTyped - looks like this caused some problems, because they trusted the docs DefinitelyTyped/DefinitelyTyped#37502 (comment)).
Expectations
API docs (4.x and 5.x) should clearly explain that req.params always is an object and how keys are assigned.