Skip to content

Commit 0a349f3

Browse files
committed
Allow directory listing and clean URLs to work at the same time
1 parent be7138d commit 0a349f3

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/index.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const applicable = (decodedPath, configEntry, negative) => {
189189
let matches = negative ? false : true;
190190

191191
if (typeof configEntry !== 'undefined') {
192-
matches = (configEntry === !negative);
192+
matches = (configEntry === !matches);
193193

194194
if (!matches && Array.isArray(configEntry)) {
195195
// This is much faster than `.some`
@@ -242,13 +242,7 @@ const findRelated = async (current, relativePath, stat, extension = '.html') =>
242242

243243
// At this point, no `.html` files have been found, so we
244244
// need to check for the existance of `.htm` ones.
245-
const relatedHTM = findRelated(current, relativePath, stat, '.htm');
246-
247-
if (relatedHTM) {
248-
return relatedHTM;
249-
}
250-
251-
return null;
245+
return findRelated(current, relativePath, stat, '.htm');
252246
};
253247

254248
const canBeListed = (excluded, file) => {
@@ -382,11 +376,7 @@ const renderDirectory = async (current, acceptsJSON, handlers, config, paths) =>
382376
paths: subPaths
383377
};
384378

385-
if (acceptsJSON) {
386-
return JSON.stringify(spec);
387-
}
388-
389-
return template(spec);
379+
return acceptsJSON ? JSON.stringify(spec) : template(spec);
390380
};
391381

392382
module.exports = async (request, response, config = {}, methods = {}) => {

0 commit comments

Comments
 (0)