From 03b6b1e15c621cc66795e6fc438817e22fbadbc9 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 28 Jul 2015 10:36:51 -0400 Subject: [PATCH] Fixed crash on launch if no hooks listen to filter:router.page A previous commit added a new hook, although it executed async.each on a var without a null check, so if no hooks were registered, it was null, and not an empty array, causing async to crash. --- src/middleware/middleware.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index 7295efbb7f..093362c433 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -67,7 +67,7 @@ middleware.pageView = function(req, res, next) { }; middleware.pluginHooks = function(req, res, next) { - async.each(plugins.loadedHooks['filter:router.page'], function(hookObj, next) { + async.each(plugins.loadedHooks['filter:router.page'] || [], function(hookObj, next) { hookObj.method(req, res, next) }, function(req, res) { // If it got here, then none of the subscribed hooks did anything, or there were no hooks