Reputation: 914
Do these two express.js routes match?
/:campus/:tlf_id/message
/:campus/:message_id/reply
In express.js it seem that the do. I'm not sure I understand this correctly.
That is, if requesting /12/90/reply
might it be caught by /:campus/:tlf_id/message
?
Upvotes: 1
Views: 1122
Reputation:
The 2 routes are not the same. because the word after the :
determines that it's a parameter that will be used and accessed so parameters values could be equal like that tlf_id = 12
and message_id = 12
so the route in this case could be /2/12
in both routes but the last keyword is what determines which route will be accessed so if both values are the same it will be
/2/12/message
/2/12/reply
so what will matter then is the last keyword you are using.
Upvotes: 0
Reputation: 686
They Actually don't match.Both links are different from each other.You should add : after 3rd / for both links to be same.
Upvotes: 0
Reputation: 43066
They don't match because the 3rd url part is not prefixed with a colon. The colon prefix on the first 2 turns them into a named parameters and match anything other than /
. The 3rd part will be a required match. So the over simplified RegEx for the routes would be /([^/]+)/([^/]+)/message
and /([^/]+)/([^/]+)/reply
.
Upvotes: 1