Express routes parameter conditions
问题 I have a route on my Express app that looks like this: app.get('/:id', function (request, response) { … }); The ID will always be a number. However, at the moment this route is matching other things, such as /login . I think I want two things from this: to only use this route if the ID is a number, and only if there isn't a route for that specific paramater already defined (such as the clash with /login ). Can this be done? 回答1: Expanding on Marius's answer, you can provide the regex AND the