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

named groups in regex routers not supported? #4277

Closed
its-dibo opened this issue May 14, 2020 · 1 comment · Fixed by #5603
Closed

named groups in regex routers not supported? #4277

its-dibo opened this issue May 14, 2020 · 1 comment · Fixed by #5603

Comments

@its-dibo
Copy link

// /regex/hello -> matches
app.get(/\/regex\/(.+)/, (req, res) => res.json({ params: req.params }));

//named groups not suppoted?
//  /regex/hello -> error
app.get(/\/regex2\/(?<groupname>.+)/, (req, res) =>
  res.json({ params: req.params })
);

when using named capture groups, I got the following error

TypeError: Cannot read property 'name' of undefined
    at Layer.match (webpack:///./node_modules/express/lib/router/layer.js?:147:20)
    at matchLayer (webpack:///./node_modules/express/lib/router/index.js?:574:18)
    at next (webpack:///./node_modules/express/lib/router/index.js?:220:15)
    at cors (webpack:///./node_modules/cors/lib/index.js?:188:7)
    at eval (webpack:///./node_modules/cors/lib/index.js?:224:17)
    at originCallback (webpack:///./node_modules/cors/lib/index.js?:214:15)
    at eval (webpack:///./node_modules/cors/lib/index.js?:219:13)
    at optionsCallback (webpack:///./node_modules/cors/lib/index.js?:199:9)
    at corsMiddleware (webpack:///./node_modules/cors/lib/index.js?:204:7)
    at Layer.handle [as handle_request] (webpack:///./node_modules/express/lib/router/layer.js?:95:5)
    at trim_prefix (webpack:///./node_modules/express/lib/router/index.js?:317:13)
    at eval (webpack:///./node_modules/express/lib/router/index.js?:284:7)
    at Function.process_params (webpack:///./node_modules/express/lib/router/index.js?:335:12)
    at next (webpack:///./node_modules/express/lib/router/index.js?:275:10)
    at urlencodedParser (webpack:///./node_modules/body-parser/lib/types/urlencoded.js?:91:7)
    at Layer.handle [as handle_request] (webpack:///./node_modules/express/lib/router/layer.js?:95:5)
@dougwilson
Copy link
Contributor

No, they are not supported, but no reason why support cannot be added 👍 . If you (or anyone else) would like to add support for this, please go ahead and open a pull request against our router engine code: https://github.com/pillarjs/router

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

Successfully merging a pull request may close this issue.

3 participants