Socket
Socket
Sign inDemoInstall

ecstatic

Package Overview
Dependencies
Maintainers
2
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 1.1.3 to 1.2.0

test.js

3

CHANGELOG.md

@@ -0,1 +1,4 @@

2015/11/03 Version 1.2.0
- opts.cache supports function argument
2015/10/03 Version 1.1.3

@@ -2,0 +5,0 @@ - Add CORS=false to defaults

@@ -227,4 +227,13 @@ #! /usr/bin/env node

res.setHeader('last-modified', (new Date(stat.mtime)).toUTCString());
res.setHeader('cache-control', cache);
if (typeof cache === 'function') {
var requestSpecificCache = cache(pathname);
if (typeof requestSpecificCache === 'number') {
requestSpecificCache = 'max-age=' + requestSpecificCache;
}
res.setHeader('cache-control', requestSpecificCache);
} else {
res.setHeader('cache-control', cache);
}
// Return a 304 if necessary

@@ -277,3 +286,3 @@ if (shouldReturn304(req, stat)) {

if (clientEtag) {
if (opts.weakCompare && clientEtag !== serverEtag
if (opts.weakCompare && clientEtag !== serverEtag
&& clientEtag !== ('W/' + serverEtag) && ('W/' + clientEtag) !== serverEtag) {

@@ -280,0 +289,0 @@ return false;

2

lib/ecstatic/etag.js
module.exports = function (stat, weakEtag) {
var etag = JSON.stringify([stat.ino, stat.size, stat.mtime].join('-'));
var etag = '"' + [stat.ino, stat.size, JSON.stringify(stat.mtime)].join('-') + '"';
if (weakEtag) {

@@ -4,0 +4,0 @@ etag = 'W/' + etag;

@@ -64,5 +64,8 @@ // This is so you can have options aliasing and defaults in one place.

}
else if(typeof opts.cache === 'number') {
else if (typeof opts.cache === 'number') {
cache = 'max-age=' + opts.cache;
}
else if (typeof opts.cache === 'function') {
cache = opts.cache
}
}

@@ -69,0 +72,0 @@

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

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

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

@@ -86,3 +86,3 @@ # Ecstatic [![build status](https://secure.travis-ci.org/jfhbrook/node-ecstatic.png)](http://travis-ci.org/jfhbrook/node-ecstatic)

### `opts.root`
### `opts.root`

@@ -103,2 +103,4 @@ `opts.root` is the directory you want to serve up.

If it is a function, it will be executed on every request, and passed the pathname. Whatever it returns, string or number, will be used as the cache control header like above.
### `opts.showDir`

@@ -165,3 +167,3 @@

Can either be a path to a [`.types`](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) file or an object hash of type(s).
ecstatic({ mimeType: { 'mime-type': ['file_extension', 'file_extension'] } })

@@ -168,0 +170,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc