Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add compatibility layer for new connect/send (fixes #43)

  • Loading branch information...
commit 5c6816d2fbd14d177d315a1b013fcbdabb5f6ebc 1 parent aa0b6cd
Almad authored July 09, 2012

Showing 1 changed file with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. 11  lib/staticGzip.js
11  lib/staticGzip.js
@@ -19,6 +19,16 @@ try {
19 19
 } catch (e) {
20 20
 	staticSend = require('express').static.send;
21 21
 }
  22
+if (!staticSend) {
  23
+  // hack for the new connect where .send is extracted
  24
+  // to send library and the helper is no longer directly exposed
  25
+  staticMiddleware = require('connect').static;
  26
+  staticSend = function(req, res, next, options) {
  27
+    return staticMiddleware(
  28
+      options.root, options
  29
+    )(req, res, next);
  30
+  }
  31
+}
22 32
 
23 33
 /**
24 34
  * Strip `Content-*` headers from `res`.
@@ -105,6 +115,7 @@ exports = module.exports = function staticGzip(dirPath, options){
105 115
 			var o = Object.create(options);
106 116
 			o.path = name;
107 117
 			o.maxAge = clientMaxAge;
  118
+			o.root = dirPath;
108 119
 			staticSend(req, res, next, o);
109 120
 		}
110 121
 

0 notes on commit 5c6816d

Please sign in to comment.
Something went wrong with that request. Please try again.