koa-static-cache
Advanced tools
Comparing version 1.0.9 to 1.0.10
1.0.10 / 2014-05-18 | ||
================== | ||
* bump fs-readdir-recursive, fixed #14 | ||
* fix bad argument handling, fixed #20 | ||
* should not return gzip buffer when accept encoding not include gzip | ||
1.0.9 / 2014-03-31 | ||
@@ -3,0 +10,0 @@ ================== |
38
index.js
@@ -11,18 +11,6 @@ var crypto = require('crypto') | ||
var stat = function (file) { | ||
return function (done) { | ||
fs.stat(file, done) | ||
} | ||
} | ||
function gzip(buf) { | ||
return function (done) { | ||
zlib.gzip(buf, done) | ||
} | ||
} | ||
module.exports = function staticCache(dir, options, files) { | ||
if (typeof dir === 'object') { | ||
files = options | ||
options = dir | ||
files = options | ||
dir = null | ||
@@ -106,5 +94,11 @@ } | ||
var acceptGzip = this.acceptsEncodings('gzip') === 'gzip'; | ||
if (file.zipBuffer) { | ||
this.set('Content-Encoding', 'gzip') | ||
this.body = file.zipBuffer | ||
if (acceptGzip) { | ||
this.set('Content-Encoding', 'gzip') | ||
this.body = file.zipBuffer | ||
} else { | ||
this.body = file.buffer | ||
} | ||
return | ||
@@ -115,3 +109,3 @@ } | ||
&& file.length > 1024 | ||
&& this.acceptsEncodings('gzip') === 'gzip' | ||
&& acceptGzip | ||
&& compressible(file.type) | ||
@@ -163,1 +157,13 @@ | ||
} | ||
var stat = function (file) { | ||
return function (done) { | ||
fs.stat(file, done) | ||
} | ||
} | ||
function gzip(buf) { | ||
return function (done) { | ||
zlib.gzip(buf, done) | ||
} | ||
} |
{ | ||
"name": "koa-static-cache", | ||
"description": "Static cache for koa", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"author": { | ||
@@ -44,3 +44,3 @@ "name": "Jonathan Ong", | ||
"compressible": "~1.0.1", | ||
"fs-readdir-recursive": "~0.0.1", | ||
"fs-readdir-recursive": ">=0.0.2", | ||
"debug": "*" | ||
@@ -47,0 +47,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10504
139
+ Addedfs-readdir-recursive@1.1.0(transitive)
- Removedfs-readdir-recursive@0.0.2(transitive)
Updatedfs-readdir-recursive@>=0.0.2