Possible bug when calling next('route') on a router prefixed with standard function middleware

26 views
Skip to first unread message

Joe Whittles

unread,
Mar 13, 2015, 2:34:15 AM3/13/15
to expre...@googlegroups.com
Whats up,

So doing some development work today, I noticed that having app.use('/foo/bar/', fn, router) where fn calls next('route') just calls the middleware in router regardless of the keyword being passed in.

So, is this well known with a good reason as to why it isn't working, or have I stumbled across an issue yet to be flagged?

To demonstrate what I mean, you can apply a patch of a test to the express repo and watch it fail.

Cheers!
failing_test.patch

Paul Vencill

unread,
Mar 13, 2015, 7:29:13 AM3/13/15
to expre...@googlegroups.com

That's expected behavior. next('route') should only be significant if you're interested in skipping the remaining route middleware and jumping to the next matching route. If there is no route middleware, then you'll see no behavioral difference with next()

--
You received this message because you are subscribed to the Google Groups "Express" group.
To unsubscribe from this group and stop receiving emails from it, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.
Visit this group at http://groups.google.com/group/express-js.
For more options, visit https://groups.google.com/d/optout.

Joe Whittles

unread,
Mar 13, 2015, 12:30:26 PM3/13/15
to expre...@googlegroups.com
See, that was my understanding, but what if the remaining middleware is a router?

The test I included in my attached patch has three route components, a middleware that calls next('route') a router that is mounted into the app which fails, and a matching route declared from the app which I expect should take over. Instead, it doesn't skip the router at all. 

Joe Whittles

unread,
Mar 13, 2015, 12:31:25 PM3/13/15
to expre...@googlegroups.com
By the way, I think you messaged me privately, can I publicise what you sent me for the sake of a discussion, or should I keep this private?

Thanks


On Friday, 13 March 2015 11:29:13 UTC, Paul wrote:
Reply all
Reply to author
Forward
0 new messages