cache-control
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,2 +6,3 @@ var path = require('path'); | ||
var url = require('fast-url-parser'); | ||
var regular = require('regular'); | ||
@@ -24,4 +25,4 @@ module.exports = function (options) { | ||
if (val === false) res.setHeader('Cache-Control', 'no-cache'); | ||
if (_.isNumber(val)) res.setHeader('Cache-Control', 'public, max-age=' + val.toString()); | ||
if (_.isString(val)) res.setHeader('Cache-Control', val); | ||
else if (isNumber(val)) res.setHeader('Cache-Control', 'public, max-age=' + val.toString()); | ||
else if (_.isString(val)) res.setHeader('Cache-Control', val); | ||
} | ||
@@ -33,3 +34,7 @@ }); | ||
next(); | ||
function isNumber (val) { | ||
return _.isNumber(val) || regular.number.test(val); | ||
} | ||
}; | ||
}; |
{ | ||
"name": "cache-control", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Express/Connect middleware to set url cache options with globs", | ||
@@ -37,4 +37,5 @@ "main": "index.js", | ||
"minimatch": "^0.4.0", | ||
"regular": "^0.1.6", | ||
"slasher": "^0.1.5" | ||
} | ||
} |
@@ -5,3 +5,3 @@ var cacheControl = require('../'); | ||
var caches = { | ||
'index.html': 1000, | ||
'index.html': "31536000", | ||
'none.html': false, | ||
@@ -22,3 +22,3 @@ 'private.html': 'private, max-age=300' | ||
.get('/index.html') | ||
.expect('Cache-Control', 'public, max-age=1000') | ||
.expect('Cache-Control', 'public, max-age=31536000') | ||
.end(done); | ||
@@ -25,0 +25,0 @@ }); |
5606
73
5
+ Addedregular@^0.1.6
+ Addedregular@0.1.6(transitive)