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

multi-parametric routing not populating req.params #1874

Open
3 tasks done
jack828 opened this issue Apr 30, 2021 · 0 comments
Open
3 tasks done

multi-parametric routing not populating req.params #1874

jack828 opened this issue Apr 30, 2021 · 0 comments

Comments

@jack828
Copy link

jack828 commented Apr 30, 2021

Hi. Thanks for a great library. I'll preface this by stating that I am upgrading some VERY legacy code (restify v4 to v8) and such have had a world of pain in doing so.

  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • Title adequately and concisely reflects the feature or the bug

Restify Version: 8.5.1
Node.js Version: 14.16.1

Expected behaviour

My req.params should be populated on all routes.

Actual behaviour

My req.params is only populated on a single route.

Repro case

const restify = require('restify')

const server = restify.createServer({})
const echoParams = (name) => (req, res, next) => {
  res.send(JSON.stringify({ params: req.params, name }))
}
server.get('/:width/:height/:mode/*', echoParams('mode'))
server.get('/:width/:height/*', echoParams('both'))
server.get('/:width/*', echoParams('width'))

server.listen(1234, () => {
  console.log('listen')
})

It does not matter what order I register my routes in, I get the same behaviour:

➜ curl localhost:1234/100/200/fill/test
"{\"params\":{\"width\":\"100\",\"height\":\"200\",\"mode\":\"fill\",\"*\":\"test\"},\"name\":\"mode\"}"%                                                                                                                                                       
➜ curl localhost:1234/100/200/test
"{\"params\":{\"*\":\"test\"},\"name\":\"both\"}"%
➜ curl localhost:1234/100/test
"{\"params\":{\"*\":\"test\"},\"name\":\"width\"}"%

Cause

I wish I knew.

EDIT: I looked at the code and dumped a ton of logging in there and can see the stuff returned here does not contain it either:
https://github.com/restify/node-restify/blob/master/lib/router.js#L84

I can't open an issue on find-my-way as this uses an extremely out of date version of it.

Are you willing and able to fix this?

Sure, if someone can point me in the right direction.

Double EDIT: I've abandoned restify because of this issue. I don't believe this package to be maintained or suitable anymore - express works just fine.

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