From 98548f04097978f0dad7eb1006766d0a3b4bccb5 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Thu, 14 Nov 2013 21:20:51 -0800 Subject: [PATCH] conditional middleware need to be `.call(this)` just realized this since we removed the top closure. i'm not sure if there's a better way to solve this, but i'd rather have this inconvenience than the extra closures. we should add tests!!! --- examples/conditional-middleware-middleware.js | 2 +- examples/conditional-middleware.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/conditional-middleware-middleware.js b/examples/conditional-middleware-middleware.js index 3bea302..92eaaeb 100644 --- a/examples/conditional-middleware-middleware.js +++ b/examples/conditional-middleware-middleware.js @@ -21,7 +21,7 @@ function ignoreAssets(mw) { if (/(\.js|\.css|\.ico)$/.test(this.path)) { yield next; } else { - yield mw(next); + yield mw.call(this, next); } } } diff --git a/examples/conditional-middleware.js b/examples/conditional-middleware.js index e793aea..aa085b6 100644 --- a/examples/conditional-middleware.js +++ b/examples/conditional-middleware.js @@ -20,7 +20,7 @@ app.use(function *(next){ yield next; } else { this.body = 'Hello World'; - yield logger(next); + yield logger.call(this, next); } });