Comparing version 2.0.6 to 2.0.7
@@ -24,9 +24,9 @@ /** | ||
send.pipe(response).on('headers', function(headers) { | ||
var message = 'URL : ' + colors.green.bold(send.url) + | ||
'\r\nPATH : ' + colors.yellow.bold(send.path) + | ||
'\r\nROOT : ' + colors.magenta.bold(send.root) + | ||
'\r\nREALPATH : ' + colors.magenta.bold(send.realpath) + | ||
'\r\nSTATUS : ' + colors.cyan.bold(send.statusCode) + | ||
'\r\nHEADERS : ' + colors.cyan.bold(JSON.stringify(headers, null, 2)) + | ||
'\r\n-----------------------------------------------------------------------------------------'; | ||
var message = 'URL : ' + colors.green.bold(send.url) | ||
+ '\r\nPATH : ' + colors.yellow.bold(send.path) | ||
+ '\r\nROOT : ' + colors.magenta.bold(send.root) | ||
+ '\r\nREALPATH : ' + colors.magenta.bold(send.realpath) | ||
+ '\r\nSTATUS : ' + colors.cyan.bold(send.statusCode) | ||
+ '\r\nHEADERS : ' + colors.cyan.bold(JSON.stringify(headers, null, 2)) | ||
+ '\r\n-----------------------------------------------------------------------------------------'; | ||
@@ -33,0 +33,0 @@ process.send(message); |
95
index.js
@@ -32,6 +32,9 @@ /*! | ||
// variable declaration | ||
// path sep | ||
var SEP = path.sep; | ||
var CWD = process.cwd(); // current working directory | ||
var MAXMAXAGE = 60 * 60 * 24 * 365; // the max max-age set | ||
// current working directory | ||
var CWD = process.cwd(); | ||
// the max max-age set | ||
var MAXMAXAGE = 60 * 60 * 24 * 365; | ||
// file not found status | ||
var NOTFOUND = ['ENOENT', 'ENAMETOOLONG', 'ENOTDIR']; | ||
@@ -83,5 +86,5 @@ | ||
context.method = context.request.method; | ||
context.charset = util.isType(options.charset, 'string') ? | ||
options.charset : | ||
null; | ||
context.charset = util.isType(options.charset, 'string') | ||
? options.charset | ||
: null; | ||
context.glob = options.glob || {}; | ||
@@ -115,7 +118,7 @@ | ||
if (!root) { | ||
root = util.isType(options.root, 'string') ? | ||
resolve(options.root) : | ||
CWD; | ||
root = util.isType(options.root, 'string') | ||
? resolve(options.root) | ||
: CWD; | ||
root = util.posixPath(join(root, SEP)); | ||
root = util.posixURI(join(root, SEP)); | ||
} | ||
@@ -139,10 +142,10 @@ | ||
path = context.url === -1 ? | ||
context.url : | ||
util.decodeURI(context._url.pathname); | ||
path = context.url === -1 | ||
? context.url | ||
: util.decodeURI(context._url.pathname); | ||
// //a/b/c ==> /a/b/c | ||
path = path === -1 ? | ||
path : | ||
path.replace(/^\/{2,}/, '/'); | ||
path = path === -1 | ||
? path | ||
: path.replace(/^\/{2,}/, '/'); | ||
} | ||
@@ -161,5 +164,5 @@ | ||
realpath = context.path === -1 ? | ||
context.path : | ||
util.posixPath(join(context.root, context.path)); | ||
realpath = context.path === -1 | ||
? context.path | ||
: util.posixURI(join(context.root, context.path)); | ||
} | ||
@@ -182,5 +185,5 @@ | ||
if (!etag) { | ||
etag = options.etag !== undefined ? | ||
Boolean(options.etag) : | ||
true; | ||
etag = options.etag !== undefined | ||
? Boolean(options.etag) | ||
: true; | ||
} | ||
@@ -216,6 +219,6 @@ | ||
ignore = ignore.filter(function(pattern) { | ||
return pattern && | ||
(util.isType(pattern, 'string') || | ||
util.isType(pattern, 'regexp') || | ||
util.isType(pattern, 'function')); | ||
return pattern | ||
&& (util.isType(pattern, 'string') | ||
|| util.isType(pattern, 'regexp') | ||
|| util.isType(pattern, 'function')); | ||
}); | ||
@@ -252,9 +255,9 @@ } | ||
if (!maxAge) { | ||
maxAge = util.isType(options.maxAge, 'string') ? | ||
ms(options.maxAge) / 1000 : | ||
Number(options.maxAge); | ||
maxAge = util.isType(options.maxAge, 'string') | ||
? ms(options.maxAge) / 1000 | ||
: Number(options.maxAge); | ||
maxAge = !isNaN(maxAge) ? | ||
Math.min(Math.max(0, maxAge), MAXMAXAGE) : | ||
0; | ||
maxAge = !isNaN(maxAge) | ||
? Math.min(Math.max(0, maxAge), MAXMAXAGE) | ||
: 0; | ||
@@ -273,5 +276,5 @@ maxAge = Math.floor(maxAge); | ||
if (!lastModified) { | ||
lastModified = options.lastModified !== undefined ? | ||
Boolean(options.lastModified) : | ||
true; | ||
lastModified = options.lastModified !== undefined | ||
? Boolean(options.lastModified) | ||
: true; | ||
} | ||
@@ -324,4 +327,4 @@ | ||
return !!(context.request.headers['if-none-match'] || | ||
context.request.headers['if-modified-since']); | ||
return !!(context.request.headers['if-none-match'] | ||
|| context.request.headers['if-modified-since']); | ||
}; | ||
@@ -338,4 +341,4 @@ | ||
return statusCode === 304 || | ||
(statusCode >= 200 && statusCode < 300); | ||
return statusCode === 304 | ||
|| (statusCode >= 200 && statusCode < 300); | ||
}; | ||
@@ -370,5 +373,5 @@ | ||
return ifRange.indexOf('"') !== -1 ? | ||
ifRange.indexOf(context.getHeader('ETag')) !== -1 : | ||
Date.parse(context.getHeader('Last-Modified')) <= Date.parse(ifRange); | ||
return ifRange.indexOf('"') !== -1 | ||
? ifRange.indexOf(context.getHeader('ETag')) !== -1 | ||
: Date.parse(context.getHeader('Last-Modified')) <= Date.parse(ifRange); | ||
}; | ||
@@ -598,5 +601,5 @@ | ||
// set fields | ||
_boundary = boundary + '\r\nContent-Range: ' + | ||
'bytes ' + start + '-' + end + | ||
'/' + size + '\r\n\r\n'; | ||
_boundary = boundary + '\r\nContent-Range: ' | ||
+ 'bytes ' + start + '-' + end | ||
+ '/' + size + '\r\n\r\n'; | ||
@@ -902,3 +905,3 @@ // set property | ||
} else { | ||
this.redirect(response, util.posixPath(path)); | ||
this.redirect(response, util.posixURI(path)); | ||
} | ||
@@ -905,0 +908,0 @@ }.bind(context)); |
@@ -104,8 +104,8 @@ /*! | ||
/** | ||
* posixPath | ||
* format path to posix style | ||
* posixURI | ||
* format URI to posix style | ||
* @param path | ||
* @returns {string} | ||
*/ | ||
posixPath: function(path) { | ||
posixURI: function(path) { | ||
return path.replace(BACKSLASH_RE, '/'); | ||
@@ -112,0 +112,0 @@ }, |
{ | ||
"name": "file-send", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "A http file send", | ||
@@ -34,4 +34,4 @@ "author": { | ||
"etag": "^1.7.0", | ||
"fresh": "^0.3.0", | ||
"mime-types": "^2.1.12", | ||
"fresh": "^0.4.0", | ||
"mime-types": "^2.1.14", | ||
"destroy": "^1.0.4", | ||
@@ -44,3 +44,3 @@ "colors": "^1.1.2", | ||
"range-parser": "^1.2.0", | ||
"readable-stream": "^2.2.1" | ||
"readable-stream": "^2.2.2" | ||
}, | ||
@@ -50,3 +50,3 @@ "devDependencies": { | ||
"chai": "^3.5.0", | ||
"superagent": "^2.3.0" | ||
"superagent": "^3.4.2" | ||
}, | ||
@@ -53,0 +53,0 @@ "readmeFilename": "README.md", |
Sorry, the diff of this file is not supported yet
42764
1170
+ Addedfresh@0.4.0(transitive)
- Removedfresh@0.3.0(transitive)
Updatedfresh@^0.4.0
Updatedmime-types@^2.1.14
Updatedreadable-stream@^2.2.2