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

docs: document req.params changes in 5.x

Open krzysdz opened this issue 2 months ago • 2 comments

Fixes #2090

krzysdz avatar Nov 01 '25 00:11 krzysdz

Deploy Preview for expressjscom-preview ready!

Name Link
Latest commit b7d13cfeb038c44493697970e534547ff7dc0242
Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6944b01af5f04f0008903599
Deploy Preview https://deploy-preview-2092--expressjscom-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Nov 01 '25 00:11 netlify[bot]

🚦 Lighthouse Results (Mobile & Desktop)

URL Device Perf A11y Best Practices
/ mobile 🔴 70 🟢 100 🟢 96
/en/blog/posts.html mobile 🔴 73 🟢 96 🟢 96
/en/5x/api.html mobile 🟠 75 🟢 95 🟢 96
/ desktop 🟢 100 🟢 100 🟢 96
/en/blog/posts.html desktop 🟢 100 🟢 96 🟢 92
/en/5x/api.html desktop 🟢 99 🟢 95 🟢 96

github-actions[bot] avatar Nov 01 '25 00:11 github-actions[bot]

Just one thing that I remembered - req.params has null prototype, unless the path is a regular expression. With regexes req.params is a normal object (see regexpMatcher in router)

krzysdz avatar Dec 18 '25 23:12 krzysdz

Your suggestion is definitely clearer. I'll admit that I'm not great at writing documentation.

There is just the question about prototype that may or may not be null... I did not notice it initially and forgot to update the PR when I tested some more things and realised that regular expressions have req.params with a regular Object prototype. To be fair this inconsistency is probably something that should be changed in router.

krzysdz avatar Dec 19 '25 00:12 krzysdz

There is just the question about prototype that may or may not be null... I did not notice it initially and forgot to update the PR when I tested some more things and realised that regular expressions have req.params with a regular Object prototype. To be fair this inconsistency is probably something that should be changed in router.

yep, when it's not regexp then the object is created here, whereas here is where the object is created, probably we should change that in the router so both ways are the same

bjohansebas avatar Dec 19 '25 01:12 bjohansebas