Skip to content

Commit

Permalink
Remove a closure
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Jan 14, 2018
1 parent bac2072 commit 8745e1a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions lib/index.js
Expand Up @@ -18,6 +18,22 @@ const internals = {
};


internals.fileMethod = function (path, responseOptions) {

// Set correct confine value

responseOptions = responseOptions || {};

if (typeof responseOptions.confine === 'undefined' || responseOptions.confine === true) {
responseOptions.confine = '.';
}

Hoek.assert(responseOptions.end === undefined || +responseOptions.start <= +responseOptions.end, 'options.start must be less than or equal to options.end');

return this.response(File.response(path, responseOptions, this.request));
};


exports.plugin = {
pkg: require('../package.json'),
once: true,
Expand All @@ -31,19 +47,6 @@ exports.plugin = {

server.decorate('handler', 'file', File.handler);
server.decorate('handler', 'directory', Directory.handler);
server.decorate('toolkit', 'file', function (path, responseOptions) {

// Set correct confine value

responseOptions = responseOptions || {};

if (typeof responseOptions.confine === 'undefined' || responseOptions.confine === true) {
responseOptions.confine = '.';
}

Hoek.assert(responseOptions.end === undefined || +responseOptions.start <= +responseOptions.end, 'options.start must be less than or equal to options.end');

return this.response(File.response(path, responseOptions, this.request));
});
server.decorate('toolkit', 'file', internals.fileMethod);
}
};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -15,7 +15,7 @@
"node": ">=8.9.0"
},
"peerDependencies": {
"hapi": "17.x.x"
"hapi": ">=17.0.0"
},
"dependencies": {
"ammo": "3.x.x",
Expand Down

0 comments on commit 8745e1a

Please sign in to comment.