Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inert

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inert - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

4

lib/directory.js

@@ -30,7 +30,5 @@ // Load modules

Joi.assert(options, internals.schema, 'Invalid directory handler options (' + route.path + ')');
var settings = Joi.attempt(options, internals.schema, 'Invalid directory handler options (' + route.path + ')');
Hoek.assert(route.path[route.path.length - 1] === '}', 'The route path must end with a parameter:', route.path);
var settings = Joi.validate(options, internals.schema).value;
var normalize = function (paths) {

@@ -37,0 +35,0 @@

@@ -33,4 +33,4 @@ // Load modules

Joi.assert(options, internals.schema, 'Invalid file handler options (' + route.path + ')');
var settings = (typeof options !== 'object' ? { path: options } : Joi.validate(options, internals.schema).value);
var settings = Joi.attempt(options, internals.schema, 'Invalid file handler options (' + route.path + ')');
settings = (typeof options !== 'object' ? { path: options } : settings);
Hoek.assert(typeof settings.path !== 'string' || settings.path[settings.path.length - 1] !== '/', 'File path cannot end with a \'/\':', route.path);

@@ -50,3 +50,3 @@

var response = exports.response(path, options, request);
var response = exports.response(path, options, request, true);
return internals.prepare(response, callback);

@@ -56,3 +56,3 @@ };

exports.response = function (path, options, request) {
exports.response = function (path, options, request, _preloaded) {

@@ -69,3 +69,5 @@ options = options || {};

return request.generateResponse(source, { variety: 'file', marshal: internals.marshal, prepare: internals.prepare, close: internals.close });
var prepare = _preloaded ? null : internals.prepare;
return request.generateResponse(source, { variety: 'file', marshal: internals.marshal, prepare: prepare, close: internals.close });
};

@@ -76,4 +78,2 @@

internals.close(response); // Close any leftover descriptors from previous prepare call
var path = response.source.path;

@@ -80,0 +80,0 @@ internals.openStat(path, 'r', function (err, fd, stat) {

{
"name": "inert",
"description": "Static file and directory handlers plugin for hapi.js",
"version": "3.0.1",
"version": "3.0.2",
"repository": "git://github.com/hapijs/inert",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

@@ -835,3 +835,26 @@ // Load modules

});
it('only stats the file system once when requesting a file', function (done) {
var orig = Fs.fstat;
var callCnt = 0;
Fs.fstat = function () {
callCnt++;
return orig.apply(Fs, arguments);
};
var server = provisionServer();
server.route({ method: 'GET', path: '/directory/{path*}', handler: { directory: { path: './' } } });
server.inject('/directory/directory.js', function (res) {
Fs.fstat = orig;
expect(callCnt).to.equal(1);
expect(res.statusCode).to.equal(200);
expect(res.payload).to.contain('hapi');
done();
});
});
});
});

Sorry, the diff of this file is not supported yet

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