I have a route that looks like this:
app.all('/path/:namedParam/*splat?',function(req,res,next){ if(!req.params.length){ // do something when there is no splat } else { // do something with splat } });
however this does not work - if I call path/foo/bar , it gets into the route, but if I call path/foo , it is not.
Is it possible to have an optional splat parameter, or do I need to use a regular expression to detect it?
Edit
to be more clear, here are the requirements I'm trying to achieve:
- first and second parameters required
- the first parameter is static, the second is a named parameter.
- any number of optional additional parameters can be added and still gets into the route.
Jesse Apr 04 '12 at 22:21 2012-04-04 22:21
source share