diff --git a/lib/staticGzip.js b/lib/staticGzip.js index 2cac1ce..fcdba80 100644 --- a/lib/staticGzip.js +++ b/lib/staticGzip.js @@ -19,6 +19,16 @@ try { } catch (e) { staticSend = require('express').static.send; } +if (!staticSend) { + // hack for the new connect where .send is extracted + // to send library and the helper is no longer directly exposed + staticMiddleware = require('connect').static; + staticSend = function(req, res, next, options) { + return staticMiddleware( + options.root, options + )(req, res, next); + } +} /** * Strip `Content-*` headers from `res`. @@ -105,6 +115,7 @@ exports = module.exports = function staticGzip(dirPath, options){ var o = Object.create(options); o.path = name; o.maxAge = clientMaxAge; + o.root = dirPath; staticSend(req, res, next, o); }