You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had checked the router Layer, and the path was undefined in almost every route, that shouldn't be the case, right?
While I don't know the reason of it being set to undefined initially, I can suggest it should be set to path. I have noticed that the path on Layer is no longer undefined if we set,
this.path=path;
Instead, it gets correct path such as /users or whatever the path actually is.
The text was updated successfully, but these errors were encountered:
It seems that this.path is being set to undefined because we can't determine what path the Layer is matched against until runtime.
Let me explain my thought process: Layers are added to the Router instance when the use and route methods are executed.
The Router.prototype.run method only accepts a string as path, but Router.prototype.use can accept either a string or an array of strings. You can refer to the Express documentation for more details.
We can't know which of the possible path values was matched until the layer is actually matched at runtime, as seen here.
To address the issue discussed in express#5961, perhaps we could add an extra property to the Layer instance, such as paths or pathPatterns. This would make it possible to list all routes or a router.
@pillarjs/express-tc, can we get your input on this matter?
Can someone please help me understand why
this.path
is set toundefined
?router/lib/layer.js
Line 43 in 2e7fb67
I had checked the router Layer, and the path was
undefined
in almost every route, that shouldn't be the case, right?While I don't know the reason of it being set to
undefined
initially, I can suggest it should be set topath
. I have noticed that thepath
on Layer is no longer undefined if we set,Instead, it gets correct path such as
/users
or whatever the path actually is.The text was updated successfully, but these errors were encountered: