Socket
Socket
Sign inDemoInstall

send

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

send - npm Package Compare versions

Comparing version 0.7.4 to 0.8.0

5

History.md

@@ -0,1 +1,6 @@

0.8.0 / 2014-08-05
==================
* Add `extensions` option
0.7.4 / 2014-08-04

@@ -2,0 +7,0 @@ ==================

60

lib/send.js

@@ -104,4 +104,8 @@

this._extensions = options.extensions !== undefined
? normalizeList(options.extensions)
: []
this._index = options.index !== undefined
? normalizeIndex(options.index)
? normalizeList(options.index)
: ['index.html']

@@ -173,3 +177,3 @@

SendStream.prototype.index = deprecate.function(function index(paths) {
var index = !paths ? [] : normalizeIndex(paths);
var index = !paths ? [] : normalizeList(paths);
debug('index %o', paths);

@@ -464,10 +468,3 @@ this._index = index;

debug('stat "%s"', path);
fs.stat(path, function(err, stat){
if (err) return self.onStatError(err);
if (stat.isDirectory()) return self.redirect(self.path);
self.emit('file', path, stat);
self.send(path, stat);
});
this.sendFile(path);
return res;

@@ -564,2 +561,43 @@ };

/**
* Transfer file for `path`.
*
* @param {String} path
* @api private
*/
SendStream.prototype.sendFile = function sendFile(path) {
var i = 0
var self = this
debug('stat "%s"', path);
fs.stat(path, function onstat(err, stat) {
if (err && err.code === 'ENOENT' && path[path.length - 1] !== sep) {
// not found, check extensions
return next(err)
}
if (err) return self.onStatError(err)
if (stat.isDirectory()) return self.redirect(self.path)
self.emit('file', path, stat)
self.send(path, stat)
})
function next(err) {
if (self._extensions.length <= i) {
return err
? self.onStatError(err)
: self.error(404)
}
var p = path + '.' + self._extensions[i++]
debug('stat "%s"', p)
fs.stat(p, function (err, stat) {
if (err) return next(err)
if (stat.isDirectory()) return next()
self.emit('file', p, stat)
self.send(p, stat)
})
}
}
/**
* Transfer index for `path`.

@@ -712,4 +750,4 @@ *

function normalizeIndex(val){
function normalizeList(val){
return [].concat(val || [])
}

2

package.json
{
"name": "send",
"description": "Better streaming static file server with Range and conditional-GET support",
"version": "0.7.4",
"version": "0.8.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -87,2 +87,8 @@ # send

#### extensions
If a given file doesn't exist, try appending one of the given extensions,
in the given order. By default, this is disabled (set to `false`). An
example value that will serve extension-less HTML files: `['html', 'htm']`.
#### index

@@ -89,0 +95,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc