Open GuskiS opened 5 years ago
Hi! Thanks for the feature request. Can you provide more information around what you expect to use this for? For example, if the route is defined as
router.get(["/user/:id", "/person/:id"], (req, res, next) => {
console.log(req.originalUnparsedPath); // => "/user/:id"
next();
});
would the expectation here be (a) you get that original array back (b) you get just the element in the array that matched the request url or (c) something else?
The feature request to too vague on what the goal is for the usage of this data is to gauge, if you can expand on what specific you're going to use it for as well. For example, what should it provide when there are routers mounted in routers?
Thanks for reply.
I wasn't aware you can use router API like that. That being said, I would expect req.originalUnparsedPath
to work same way as req.originalUrl
do, but just return the unparsed value.
router.get(["/user/:id", "/person/:id"], (req, res, next) => {
console.log({ original: req.originalUrl, unparsed: req.originalUnparsedPath });
next();
});
// => { original: "/user/123", unparsed: "/user/:id" }
// or
// => { original: "/person/123", unparsed: "/person/:id" }
// depending on request you make
I need to log it out and then create AWS metrics.
Does this PR satisfy this? https://github.com/pillarjs/router/pull/34
I suppose that would work, yes.
I cannot access originalUnparsedPath. I have express 4.18.2
As discussed in https://github.com/expressjs/express/issues/4084 there is a need for original path on req object.
Example:
originalUnparsedPath
is just an example, but the name would be something along the lines.