Express.js: how to make app.get('/[:userId]i'..) in req.param? Express.js: how to make app.get('/[:userId]i'..) in req.param? express express

Express.js: how to make app.get('/[:userId]i'..) in req.param?


Assuming you have a numerical id followed by an i and you want the id coming back as just the numerical.

app.get("/:id([0-9]+)i", function (req, res) {...});

This will match a numeric followed by an i and will give you just the numeric in req.params.id.

Example:

curl -XGET localhost:8080/124i

Gives me the following in req.params

[ 'id': 124 ]