Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hapijs/inert
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.1
Choose a base ref
...
head repository: hapijs/inert
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.2
Choose a head ref
  • 7 commits
  • 6 files changed
  • 6 contributors

Commits on May 1, 2020

  1. Correct default value for etagsCacheMaxSize

    In the source file default value for `etagsCacheMaxSize` is set to `1000` and not `10000` as stated in the API docs.
    
    https://github.com/hapijs/inert/blob/b3e4e446e960e6291e01a61c7cb666c570e0802f/lib/index.js#L13
    behnoodk authored May 1, 2020
    Copy the full SHA
    36c4a27 View commit details

Commits on May 16, 2020

  1. Merge pull request #142 from behnoodk/patch-1

    Correct default value for etagsCacheMaxSize
    hueniverse authored May 16, 2020
    Copy the full SHA
    323f503 View commit details

Commits on Jun 4, 2020

  1. Update LICENSE.md

    In the disclaimer of the above license, the last statement has a missing 's' in the word software. Needs to be updated.
    shruthi-alva authored Jun 4, 2020
    Copy the full SHA
    8baeedc View commit details
  2. Merge pull request #144 from shruthi-alva/patch-1

    Update LICENSE.md
    hueniverse authored Jun 4, 2020
    Copy the full SHA
    4d8a989 View commit details

Commits on Aug 3, 2020

  1. Copy the full SHA
    b8f9196 View commit details
  2. Merge pull request #148 from lloydbenson/master

    update lab and switch joi to validate
    lloydbenson authored Aug 3, 2020
    Copy the full SHA
    54dee22 View commit details

Commits on Aug 10, 2020

  1. v6.0.2

    cjihrig committed Aug 10, 2020
    Copy the full SHA
    2896b71 View commit details
Showing with 36 additions and 36 deletions.
  1. +1 −1 API.md
  2. +1 −1 LICENSE.md
  3. +12 −12 lib/directory.js
  4. +15 −15 lib/file.js
  5. +4 −4 lib/index.js
  6. +3 −3 package.json
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ file generated by this plugin.
**inert** handles the following server plugin options on `plugins.inert`:

- `etagsCacheMaxSize` - sets the maximum number of file etag hash values stored in the
etags cache. Defaults to `10000`.
etags cache. Defaults to `1000`.

### `h.file(path, [options])`

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 changes: 12 additions & 12 deletions lib/directory.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ const Path = require('path');
const Boom = require('@hapi/boom');
const Bounce = require('@hapi/bounce');
const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Validate = require('@hapi/validate');

const File = require('./file');
const Fs = require('./fs');
@@ -14,16 +14,16 @@ const Fs = require('./fs');
const internals = {};


internals.schema = Joi.object({
path: Joi.alternatives(Joi.array().items(Joi.string()).single(), Joi.func()).required(),
index: Joi.alternatives(Joi.boolean(), Joi.array().items(Joi.string()).single()).default(true),
listing: Joi.boolean(),
showHidden: Joi.boolean(),
redirectToSlash: Joi.boolean(),
lookupCompressed: Joi.boolean(),
lookupMap: Joi.object().min(1).pattern(/.+/, Joi.string()),
etagMethod: Joi.string().valid('hash', 'simple').allow(false),
defaultExtension: Joi.string().alphanum()
internals.schema = Validate.object({
path: Validate.alternatives(Validate.array().items(Validate.string()).single(), Validate.func()).required(),
index: Validate.alternatives(Validate.boolean(), Validate.array().items(Validate.string()).single()).default(true),
listing: Validate.boolean(),
showHidden: Validate.boolean(),
redirectToSlash: Validate.boolean(),
lookupCompressed: Validate.boolean(),
lookupMap: Validate.object().min(1).pattern(/.+/, Validate.string()),
etagMethod: Validate.string().valid('hash', 'simple').allow(false),
defaultExtension: Validate.string().alphanum()
});


@@ -47,7 +47,7 @@ internals.resolvePathOption = function (result) {

exports.handler = function (route, options) {

const settings = Joi.attempt(options, internals.schema, 'Invalid directory handler options (' + route.path + ')');
const settings = Validate.attempt(options, internals.schema, 'Invalid directory handler options (' + route.path + ')');
Hoek.assert(route.path[route.path.length - 1] === '}', 'The route path for a directory handler must end with a parameter:', route.path);

const paramName = /\w+/.exec(route.path.slice(route.path.lastIndexOf('{')))[0];
30 changes: 15 additions & 15 deletions lib/file.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ const Ammo = require('@hapi/ammo');
const Boom = require('@hapi/boom');
const Bounce = require('@hapi/bounce');
const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Validate = require('@hapi/validate');

const Etag = require('./etag');
const Fs = require('./fs');
@@ -20,27 +20,27 @@ internals.defaultMap = {
};


internals.schema = Joi.alternatives([
Joi.string(),
Joi.func(),
Joi.object({
path: Joi.alternatives(Joi.string(), Joi.func()).required(),
confine: Joi.alternatives(Joi.string(), Joi.boolean()).default(true),
filename: Joi.string(),
mode: Joi.string().valid('attachment', 'inline').allow(false),
lookupCompressed: Joi.boolean(),
lookupMap: Joi.object().min(1).pattern(/.+/, Joi.string()),
etagMethod: Joi.string().valid('hash', 'simple').allow(false),
start: Joi.number().integer().min(0).default(0),
end: Joi.number().integer().min(Joi.ref('start'))
internals.schema = Validate.alternatives([
Validate.string(),
Validate.func(),
Validate.object({
path: Validate.alternatives(Validate.string(), Validate.func()).required(),
confine: Validate.alternatives(Validate.string(), Validate.boolean()).default(true),
filename: Validate.string(),
mode: Validate.string().valid('attachment', 'inline').allow(false),
lookupCompressed: Validate.boolean(),
lookupMap: Validate.object().min(1).pattern(/.+/, Validate.string()),
etagMethod: Validate.string().valid('hash', 'simple').allow(false),
start: Validate.number().integer().min(0).default(0),
end: Validate.number().integer().min(Validate.ref('start'))
})
.with('filename', 'mode')
]);


exports.handler = function (route, options) {

let settings = Joi.attempt(options, internals.schema, 'Invalid file handler options (' + route.path + ')');
let settings = Validate.attempt(options, internals.schema, 'Invalid file handler options (' + route.path + ')');
settings = (typeof options !== 'object' ? { path: options, confine: '.' } : settings);
settings.confine = settings.confine === true ? '.' : settings.confine;
Hoek.assert(typeof settings.path !== 'string' || settings.path[settings.path.length - 1] !== '/', 'File path cannot end with a \'/\':', route.path);
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict';

const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Validate = require('@hapi/validate');

const Directory = require('./directory');
const Etag = require('./etag');
const File = require('./file');


const internals = {
schema: Joi.object({
etagsCacheMaxSize: Joi.number().integer().min(0).default(1000)
schema: Validate.object({
etagsCacheMaxSize: Validate.number().integer().min(0).default(1000)
}).required()
};

@@ -41,7 +41,7 @@ exports.plugin = {
register(server, options) {

Hoek.assert(Object.keys(options).length === 0, 'Inert does not support registration options');
const settings = Joi.attempt(Hoek.reach(server.settings.plugins, 'inert') || {}, internals.schema, 'Invalid "inert" server options');
const settings = Validate.attempt(Hoek.reach(server.settings.plugins, 'inert') || {}, internals.schema, 'Invalid "inert" server options');

server.expose('_etags', settings.etagsCacheMaxSize > 0 ? new Etag.Cache(settings.etagsCacheMaxSize) : null);

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hapi/inert",
"description": "Static file and directory handlers plugin for hapi.js",
"version": "6.0.1",
"version": "6.0.2",
"repository": "https://github.com/hapijs/inert.git",
"main": "lib/index.js",
"files": [
@@ -19,14 +19,14 @@
"@hapi/boom": "9.x.x",
"@hapi/bounce": "2.x.x",
"@hapi/hoek": "9.x.x",
"@hapi/joi": "17.x.x",
"@hapi/validate": "1.x.x",
"lru-cache": "5.x.x"
},
"devDependencies": {
"@hapi/code": "8.x.x",
"@hapi/file": "2.x.x",
"@hapi/hapi": "19.x.x",
"@hapi/lab": "22.x.x"
"@hapi/lab": "23.x.x"
},
"scripts": {
"test": "lab -f -a @hapi/code -t 100 -L",