Skip to content

Commit

Permalink
Further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Aug 21, 2020
1 parent a6a8a73 commit 58e851b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ internals.generateListing = async function (path, resource, selection, hasTraili
html = html + '<li><a href="' + internals.pathEncode(parent) + '">Parent Directory</a></li>';
}

for (let i = 0; i < files.length; ++i) {
for (const file of files) {
if (settings.showHidden ||
!internals.isFileHidden(files[i])) {
!internals.isFileHidden(file)) {

html = html + '<li><a href="' + internals.pathEncode(resource + (!hasTrailingSlash ? '/' : '') + files[i]) + '">' + Hoek.escapeHtml(files[i]) + '</a></li>';
html = html + '<li><a href="' + internals.pathEncode(resource + (!hasTrailingSlash ? '/' : '') + file) + '">' + Hoek.escapeHtml(file) + '</a></li>';
}
}

Expand Down
7 changes: 4 additions & 3 deletions lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ exports.response = function (path, options, request, _preloaded) {

internals.prepare = async function (response) {

const { source } = response;
const { request, source } = response;
const { settings, path } = source;

if (path === null) {
Expand All @@ -115,7 +115,7 @@ internals.prepare = async function (response) {
}

if (!response.headers['content-type']) {
response.type(response.request.server.mime.path(path).type || 'application/octet-stream');
response.type(request.server.mime.path(path).type || 'application/octet-stream');
}

response.header('last-modified', stat.mtime.toUTCString());
Expand Down Expand Up @@ -177,10 +177,11 @@ internals.marshal = async function (response) {
internals.addContentRange = function (response) {

const { request } = response;
const length = response.headers['content-length'];
let range = null;

if (request.route.settings.response.ranges) {
const length = response.headers['content-length'];

if (request.headers.range && length) {

// Check If-Range
Expand Down

0 comments on commit 58e851b

Please sign in to comment.