send
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -0,1 +1,13 @@ | ||
0.6.0 / 2014-07-11 | ||
================== | ||
* Deprecate `from` option; use `root` option | ||
* Deprecate `send.etag()` -- use `etag` in `options` | ||
* Deprecate `send.hidden()` -- use `hidden` in `options` | ||
* Deprecate `send.index()` -- use `index` in `options` | ||
* Deprecate `send.maxage()` -- use `maxAge` in `options` | ||
* Deprecate `send.root()` -- use `root` in `options` | ||
* deps: debug@1.0.3 | ||
- Add support for multiple wildcards in namespaces | ||
0.5.0 / 2014-06-28 | ||
@@ -2,0 +14,0 @@ ================== |
@@ -7,2 +7,3 @@ | ||
var debug = require('debug')('send') | ||
var deprecate = require('depd')('send') | ||
var escapeHtml = require('escape-html') | ||
@@ -24,2 +25,6 @@ , parseRange = require('range-parser') | ||
/** | ||
* Variables. | ||
*/ | ||
var maxMaxAge = 60 * 60 * 24 * 365 * 1000; // 1 year | ||
var upPathRegexp = /(?:^|[\\\/])\.\.(?:[\\\/]|$)/; | ||
@@ -83,7 +88,28 @@ | ||
this.options = options; | ||
this.etag(('etag' in options) ? options.etag : true); | ||
this.maxage(options.maxage); | ||
this.hidden(options.hidden); | ||
this.index(('index' in options) ? options.index : 'index.html'); | ||
if (options.root || options.from) this.root(options.root || options.from); | ||
this._etag = options.etag !== undefined | ||
? Boolean(options.etag) | ||
: true | ||
this._hidden = Boolean(options.hidden) | ||
this._index = options.index !== undefined | ||
? normalizeIndex(options.index) | ||
: ['index.html'] | ||
this._maxage = options.maxAge || options.maxage | ||
this._maxage = typeof this._maxage === 'string' | ||
? ms(this._maxage) | ||
: Number(this._maxage) | ||
this._maxage = !isNaN(this._maxage) | ||
? Math.min(Math.max(0, this._maxage), maxMaxAge) | ||
: 0 | ||
this._root = options.root | ||
? normalize(options.root) | ||
: null | ||
if (!this._root && options.from) { | ||
this.from(options.from); | ||
} | ||
} | ||
@@ -105,3 +131,3 @@ | ||
SendStream.prototype.etag = function(val){ | ||
SendStream.prototype.etag = deprecate.function(function etag(val) { | ||
val = Boolean(val); | ||
@@ -111,3 +137,3 @@ debug('etag %s', val); | ||
return this; | ||
}; | ||
}, 'send.etag: pass etag as option'); | ||
@@ -122,3 +148,3 @@ /** | ||
SendStream.prototype.hidden = function(val){ | ||
SendStream.prototype.hidden = deprecate.function(function hidden(val) { | ||
val = Boolean(val); | ||
@@ -128,3 +154,3 @@ debug('hidden %s', val); | ||
return this; | ||
}; | ||
}, 'send.hidden: pass hidden as option'); | ||
@@ -140,8 +166,8 @@ /** | ||
SendStream.prototype.index = function index(paths){ | ||
var index = !paths ? [] : Array.isArray(paths) ? paths : [paths]; | ||
SendStream.prototype.index = deprecate.function(function index(paths) { | ||
var index = !paths ? [] : normalizeIndex(paths); | ||
debug('index %o', paths); | ||
this._index = index; | ||
return this; | ||
}; | ||
}, 'send.index: pass index as option'); | ||
@@ -156,4 +182,3 @@ /** | ||
SendStream.prototype.root = | ||
SendStream.prototype.from = function(path){ | ||
SendStream.prototype.root = function(path){ | ||
path = String(path); | ||
@@ -164,2 +189,8 @@ this._root = normalize(path); | ||
SendStream.prototype.from = deprecate.function(SendStream.prototype.root, | ||
'send.from: pass root as option'); | ||
SendStream.prototype.root = deprecate.function(SendStream.prototype.root, | ||
'send.root: pass root as option'); | ||
/** | ||
@@ -173,3 +204,3 @@ * Set max-age to `maxAge`. | ||
SendStream.prototype.maxage = function maxage(maxAge){ | ||
SendStream.prototype.maxage = deprecate.function(function maxage(maxAge) { | ||
maxAge = typeof maxAge === 'string' | ||
@@ -183,3 +214,3 @@ ? ms(maxAge) | ||
return this; | ||
}; | ||
}, 'send.maxage: pass maxAge as option'); | ||
@@ -446,2 +477,4 @@ /** | ||
debug('options %o', options); | ||
// set header fields | ||
@@ -638,1 +671,12 @@ this.setHeader(path, stat); | ||
}; | ||
/** | ||
* Normalize the index option into an array. | ||
* | ||
* @param {boolean|string|array} val | ||
* @api private | ||
*/ | ||
function normalizeIndex(val){ | ||
return [].concat(val || []) | ||
} |
{ | ||
"name": "send", | ||
"description": "Better streaming static file server with Range and conditional-GET support", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -17,3 +17,4 @@ "contributors": [ | ||
"dependencies": { | ||
"debug": "1.0.2", | ||
"debug": "1.0.3", | ||
"depd": "0.3.0", | ||
"escape-html": "1.0.1", | ||
@@ -27,3 +28,3 @@ "finished": "1.2.2", | ||
"devDependencies": { | ||
"istanbul": "0.2.10", | ||
"istanbul": "0.3.0", | ||
"mocha": "~1.20.0", | ||
@@ -30,0 +31,0 @@ "should": "~4.0.0", |
@@ -82,3 +82,3 @@ # send | ||
#### maxage | ||
#### maxAge | ||
@@ -102,26 +102,2 @@ Provide a max-age in milliseconds for http caching, defaults to 0. | ||
### .etag(bool) | ||
Enable or disable etag generation, defaults to true. | ||
### .root(dir) | ||
Serve files relative to `path`. Aliased as `.from(dir)`. | ||
### .index(paths) | ||
By default send supports "index.html" files, to disable this | ||
invoke `.index(false)` or to supply a new index pass a string | ||
or an array in preferred order. | ||
### .maxage(ms) | ||
Provide a max-age in milliseconds for http caching, defaults to 0. | ||
This can also be a string accepted by the | ||
[ms](https://www.npmjs.org/package/ms#readme) module. | ||
### .hidden(bool) | ||
Enable or disable transfer of hidden files, defaults to false. | ||
## Error-handling | ||
@@ -128,0 +104,0 @@ |
23154
586
8
149
+ Addeddepd@0.3.0
+ Addeddebug@1.0.3(transitive)
+ Addeddepd@0.3.0(transitive)
- Removeddebug@1.0.2(transitive)
Updateddebug@1.0.3