I am encountering an issue with the following two routes:
router.get('/:postId([0-9]*)', handler)
router.get('/:postId([0-9]*)/like', handler)
The first route is intended to only capture URLs like /posts/4352/
, not /posts/3422/like
. However, it seems to be matching both. I tested this using the official express route tester tool and it worked as expected there. (Try entering /posts/:postId([0-9]*)
and /posts/2/like
in the tester to see it doesn't match.)
What could be causing this incorrect matching in my case?
Note: I am aware that reordering the routes will fix the issue, but I am curious about why this behavior is occurring.