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.1 to 0.1.2-1

44

lib/ecstatic.js

@@ -24,3 +24,3 @@ var path = require('path'),

pathname = decodeURI(parsed.pathname),
file = path.normalize(path.join(root, parsed.pathname));
file = path.normalize(path.join(root, pathname));

@@ -42,17 +42,26 @@ // Set common headers.

// retry for ./404.html, if that's not there then return 404
// TODO: Make this pluggable/configurable.
var handler = (typeof next === 'function' && !autoIndex)
? next
: function () {
showDir(file, pathname, stat, cache)(req, res);
};
middleware({
url: '/404.html',
statusCode: 404 // Override the response
}, res, function (req, res, next) {
if (req.statusCode == 404) {
// This means we're already trying ./404.html
status[404](res, next);
});
}
else if(req.showDir) {
// In this case, we were probably attempting to autoindex with
// 'index.html' and it didn't work. This should prompt the
// "showdir" function, which should've been set to `next`.
// TODO: Re-evaluate this dependence on recursion. Could the confusion
// introduced be eliminated?
// TODO: We're attaching this random property to req to make it work,
// which is BAD FORM. This *needs* a refactor but I think making it
// not broken is the lesser of two evils.
// NOTE: Alternate check here was:
// `path.basename(req.url) === 'index.html' && autoIndex
next();
}
else {
// Try for ./404.html
middleware({
url: '/404.html',
statusCode: 404 // Override the response status code
}, res, next);
}
}

@@ -69,7 +78,8 @@ else if (err) {

: function () {
showDir(file, pathname, stat, cache)(req, res);
showDir(root, pathname, stat, cache)(req, res);
};
middleware({
url: path.join(pathname, '/index.html')
url: path.join(pathname, '/index.html'),
showDir: true
}, res, handler);

@@ -76,0 +86,0 @@ }

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

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

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

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