Socket
Socket
Sign inDemoInstall

ecstatic

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecstatic - npm Package Compare versions

Comparing version 0.4.13 to 0.5.1

CONTRIBUTE.md

55

lib/ecstatic.js

@@ -144,3 +144,35 @@ #! /usr/bin/env node

function serve(stat) {
// Do a MIME lookup, fall back to octet-stream and handle gzip
// special case.
var contentType = mime.lookup(file), charSet;
if (contentType) {
charSet = mime.charsets.lookup(contentType, 'utf-8');
if (charSet) {
contentType += '; charset=' + charSet;
}
}
if (path.extname(file) === '.gz') {
res.setHeader('Content-Encoding', 'gzip');
// strip gz ending and lookup mime type
contentType = mime.lookup(path.basename(file, ".gz"));
}
var range = (req.headers && req.headers['range']);
if (range) {
var total = stat.size;
var parts = range.replace(/bytes=/, "").split("-");
var partialstart = parts[0];
var partialend = parts[1];
var start = parseInt(partialstart, 10);
var end = partialend ? parseInt(partialend, 10) : total-1;
var chunksize = (end-start)+1;
var fstream = fs.createReadStream(file, {start: start, end: end});
res.writeHead(206, { 'Content-Range': 'bytes ' + start + '-' + end + '/' + total, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize, 'Content-Type': contentType || 'application/octet-stream' });
fstream.pipe(res);
return;
}
// TODO: Helper for this, with default headers.

@@ -162,21 +194,2 @@ res.setHeader('etag', etag(stat));

res.setHeader('content-length', stat.size);
// Do a MIME lookup, fall back to octet-stream and handle gzip
// special case.
var contentType = mime.lookup(file), charSet;
if (contentType) {
charSet = mime.charsets.lookup(contentType);
if (charSet) {
contentType += '; charset=' + charSet;
}
}
if (path.extname(file) === '.gz') {
res.setHeader('Content-Encoding', 'gzip');
// strip gz ending and lookup mime type
contentType = mime.lookup(path.basename(file, ".gz"));
}
res.setHeader('content-type', contentType || 'application/octet-stream');

@@ -222,3 +235,3 @@

var http = require('http'),
opts = require('optimist').argv,
opts = require('minimist')(process.argv.slice(2)),
port = opts.port || opts.p || 8000,

@@ -236,4 +249,4 @@ dir = opts.root || opts._[0] || process.cwd();

.listen(port, function () {
console.log('ecstatic serving ' + dir + ' on port ' + port);
console.log('ecstatic serving ' + dir + ' at http://0.0.0.0:' + port);
});
}

@@ -6,3 +6,3 @@ // This is so you can have options aliasing and defaults in one place.

var autoIndex = true,
showDir = false,
showDir = true,
humanReadable = true,

@@ -9,0 +9,0 @@ si = false,

@@ -5,3 +5,3 @@ {

"description": "A simple static file server middleware that works with both Express and Flatiron",
"version": "0.4.13",
"version": "0.5.1",
"homepage": "https://github.com/jesusabdullah/node-ecstatic",

@@ -28,3 +28,3 @@ "repository": {

"ent": "0.0.x",
"optimist": "~0.3.5"
"minimist": "~0.0.5"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -101,10 +101,5 @@ # Ecstatic [![build status](https://secure.travis-ci.org/jesusabdullah/node-ecstatic.png)](http://travis-ci.org/jesusabdullah/node-ecstatic)

### `opts.autoIndex`
Serve `/path/index.html` when `/path/` is requested.
Turn **off** autoIndexing with `opts.autoIndex === false`. Defaults to **true**.
### `opts.humanReadable`
If autoIndexing is enabled, add human-readable file sizes. Defaults to **true**.
If showDir is enabled, add human-readable file sizes. Defaults to **true**.
Aliases are `humanreadable` and `human-readable`.

@@ -114,6 +109,11 @@

If autoIndexing and humanReadable are enabled, print file sizes with base 1000 instead
If showDir and humanReadable are enabled, print file sizes with base 1000 instead
of base 1024. Name is inferred from cli options for `ls`. Aliased to `index`, the
equivalent option in Apache.
### `opts.autoIndex`
Serve `/path/index.html` when `/path/` is requested.
Turn **off** autoIndexing with `opts.autoIndex === false`. Defaults to **true**.
### `opts.defaultExt`

@@ -155,6 +155,16 @@

npm test
Ecstatic has a fairly extensive test suite. You can run it with:
```sh
$ npm test
```
# Contribute:
Without outside contributions, ecstatic would wither and die! Before
contributing, take a quick look at the contributing guidelines in
./CONTRIBUTE.md . They're relatively painless, I promise.
# License:
MIT.

@@ -22,2 +22,7 @@ module.exports = {

},
'e.js' : {
code : 200,
type : 'application/javascript',
body : 'console.log(\'π!!!\');\n',
},
'subdir/e.html' : {

@@ -24,0 +29,0 @@ code : 200,

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