Skip to content

Commit

Permalink
Allow directory listing and clean URLs to work at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed May 24, 2018
1 parent be7138d commit 0a349f3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const applicable = (decodedPath, configEntry, negative) => {
let matches = negative ? false : true;

if (typeof configEntry !== 'undefined') {
matches = (configEntry === !negative);
matches = (configEntry === !matches);

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

// At this point, no `.html` files have been found, so we
// need to check for the existance of `.htm` ones.
const relatedHTM = findRelated(current, relativePath, stat, '.htm');

if (relatedHTM) {
return relatedHTM;
}

return null;
return findRelated(current, relativePath, stat, '.htm');
};

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

if (acceptsJSON) {
return JSON.stringify(spec);
}

return template(spec);
return acceptsJSON ? JSON.stringify(spec) : template(spec);
};

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

0 comments on commit 0a349f3

Please sign in to comment.