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.1.6 to 0.1.7

.npmignore

15

lib/ecstatic.js

@@ -17,4 +17,5 @@ var path = require('path'),

cache = opts.cache,
autoIndex = opts.autoIndex;
autoIndex = opts.autoIndex,
defaultExt = opts.defaultExt;
return function middleware (req, res, next) {

@@ -29,3 +30,2 @@

res.setHeader('server', 'ecstatic-'+version);
res.setHeader('date', (new Date()).toUTCString());

@@ -60,2 +60,11 @@ if (file.slice(0, root.length) !== root) {

}
else if (defaultExt && !path.extname(req.url).length) {
//
// If no file extension is specified and there is a default extension
// try that before rendering 404.html.
//
middleware({
url: req.url + '.' + defaultExt
}, res, next);
}
else {

@@ -62,0 +71,0 @@ // Try for ./404.html

14

lib/ecstatic/opts.js

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

var defaultExt;
if (opts && opts.defaultExt) {
if (opts.defaultExt === true) {
defaultExt = 'html';
}
else {
defaultExt = opts.defaultExt;
}
}
return {
cache: (opts && opts.cache) || 3600,
autoIndex: autoIndex
autoIndex: autoIndex,
defaultExt: defaultExt
}
}

@@ -60,3 +60,3 @@ var ecstatic = require('../ecstatic'),

}
if (--pending === 0) {

@@ -90,3 +90,3 @@ cb(errs, dirs, files);

+ ent.encode(encodeURI(
((req.url == '/') ? '' : req.url)
req.url.replace(/\/$/, '')
+ '/'

@@ -93,0 +93,0 @@ + file

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

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

@@ -8,0 +8,0 @@ "repository": {

@@ -57,3 +57,9 @@ # Ecstatic

```
### fall through
To allow fall through to your custom routes:
```js
ecstatic(__dirname + '/public', {handleError: false})
```
# API:

@@ -69,2 +75,4 @@

Turn on default file extensions with `opts.defaultExt`. If `opts.defaultExt` is true, it will default to `html`. For example if you want a request to /a-file to server /root/a-file.html set this to `true`. If you want to serve /root/a-file.json set `opts.defaultExt` to `json`.
### middleware(req, res, next);

@@ -71,0 +79,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