Socket
Socket
Sign inDemoInstall

serve-static

Package Overview
Dependencies
7
Maintainers
5
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.1.0

6

History.md

@@ -0,1 +1,7 @@

1.1.0 / 2014-04-24
==================
* Accept options directly to `send` module
* deps: send@0.3.0
1.0.4 / 2014-04-07

@@ -2,0 +8,0 @@ ==================

34

index.js

@@ -41,2 +41,4 @@ /*!

*
* Further options are forwarded on to `send`.
*
* @param {String} root

@@ -49,3 +51,3 @@ * @param {Object} options

exports = module.exports = function(root, options){
options = options || {};
options = extend({}, options);

@@ -61,4 +63,9 @@ // root required

// setup options for send
options.maxage = options.maxage || options.maxAge || 0;
options.root = root;
return function staticMiddleware(req, res, next) {
if ('GET' != req.method && 'HEAD' != req.method) return next();
var opts = extend({}, options);
var originalUrl = url.parse(req.originalUrl || req.url);

@@ -86,7 +93,3 @@ var path = parseurl(req).pathname;

send(req, path)
.maxage(options.maxAge || 0)
.root(root)
.index(options.index || 'index.html')
.hidden(options.hidden)
send(req, path, opts)
.on('error', error)

@@ -122,1 +125,20 @@ .on('directory', directory)

};
/**
* Shallow clone a single object.
*
* @param {Object} obj
* @param {Object} source
* @return {Object}
* @api private
*/
function extend(obj, source) {
if (!source) return obj;
for (var prop in source) {
obj[prop] = source[prop];
}
return obj;
};

6

package.json
{
"name": "serve-static",
"description": "Serve static files",
"version": "1.0.4",
"version": "1.1.0",
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",

@@ -16,3 +16,3 @@ "license": "MIT",

"parseurl": "1.0.1",
"send": "0.2.0"
"send": "0.3.0"
},

@@ -23,3 +23,3 @@ "devDependencies": {

"should": "~3.3.0",
"supertest": "~0.10.0"
"supertest": "~0.11.0"
},

@@ -26,0 +26,0 @@ "engines": {

@@ -15,3 +15,3 @@ # Serve Static

app.use(serveStatic('public/ftp', {'index': 'default.html'}));
app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}));
app.listen();

@@ -18,0 +18,0 @@ ```

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc