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 4.0.4 to 4.1.0

2

lib/directory.js

@@ -26,2 +26,3 @@ 'use strict';

lookupCompressed: Joi.boolean(),
lookupMap: Joi.object().min(1).pattern(/.+/, Joi.string()),
etagMethod: Joi.string().valid('hash', 'simple').allow(false),

@@ -98,2 +99,3 @@ defaultExtension: Joi.string().alphanum()

lookupCompressed: settings.lookupCompressed,
lookupMap: settings.lookupMap,
etagMethod: settings.etagMethod

@@ -100,0 +102,0 @@ };

44

lib/file.js

@@ -19,2 +19,7 @@ 'use strict';

internals.defaultMap = {
gzip: '.gz'
};
internals.schema = Joi.alternatives([

@@ -29,2 +34,3 @@ Joi.string(),

lookupCompressed: Joi.boolean(),
lookupMap: Joi.object().min(1).pattern(/.+/, Joi.string()),
etagMethod: Joi.string().valid('hash', 'simple').allow(false)

@@ -136,25 +142,29 @@ })

if (!response.source.settings.lookupCompressed ||
!response.request.connection.settings.compression ||
response.request.info.acceptEncoding !== 'gzip') {
if (response.source.settings.lookupCompressed &&
response.request.connection.settings.compression) {
return internals.openStream(response, response.source.path, next);
}
const lookupMap = response.source.settings.lookupMap || internals.defaultMap;
const encoding = response.request.info.acceptEncoding;
const extension = lookupMap.hasOwnProperty(encoding) ? lookupMap[encoding] : null;
if (extension) {
const gzFile = `${response.source.path}${extension}`;
return internals.openStat(gzFile, 'r', (err, fd, stat) => {
const gzFile = response.source.path + '.gz';
internals.openStat(gzFile, 'r', (err, fd, stat) => {
if (err) {
return internals.openStream(response, response.source.path, next);
}
if (err) {
return internals.openStream(response, response.source.path, next);
}
internals.close(response);
response.source.fd = fd;
internals.close(response);
response.source.fd = fd;
response.bytes(stat.size);
response.header('content-encoding', encoding);
response.vary('accept-encoding');
response.bytes(stat.size);
response.header('content-encoding', 'gzip');
response.vary('accept-encoding');
return internals.openStream(response, gzFile, next);
});
}
}
return internals.openStream(response, gzFile, next);
});
return internals.openStream(response, response.source.path, next);
};

@@ -161,0 +171,0 @@

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

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

@@ -160,5 +160,7 @@ # inert

- `'inline'`
- `lookupCompressed` - if `true`, looks for the same filename with the '.gz' suffix for a
pre-compressed version of the file to serve if the request supports content encoding.
- `lookupCompressed` - if `true`, looks for for a pre-compressed version of the file with
the same filename with an extension, depending on the accepted encoding.
Defaults to `false`.
- `lookupMap` - an `object` which maps content encoding to expected file name extension.
Defaults to `{ gzip: '.gz' }.
- `etagMethod` - specifies the method used to calculate the `ETag` header response.

@@ -197,5 +199,7 @@ Available values:

- `'inline'`
- `lookupCompressed` - if `true`, looks for the same filename with the '.gz' suffix
for a pre-compressed version of the file to serve if the request supports content
encoding. Defaults to `false`.
- `lookupCompressed` - if `true`, looks for for a pre-compressed version of the file with
the same filename with an extension, depending on the accepted encoding.
Defaults to `false`.
- `lookupMap` - an `object` which maps content encoding to expected file name extension.
Defaults to `{ gzip: '.gz' }.
- `etagMethod` - specifies the method used to calculate the `ETag` header response.

@@ -202,0 +206,0 @@ Available values:

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