Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add option "serveIndex" to enable/disable serveIndex middleware #1752

Merged
merged 12 commits into from
Apr 5, 2019
Merged
2 changes: 1 addition & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class Server {

if (
contentBase !== false &&
(options.serveIndex || typeof options.serveIndex === 'undefined')
(options.serveIndex || options.serveIndex === undefined)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just simplify:

const shouldHandleServeIndex = contentBase || options.serveIndex

serveIndex by default should be true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evilebottnawi i've simplified the condition & i added a comment to elaborate why i'm comparing with undefined

          if (contentBase !== false) {
    // checking if it's set to true or not set (Default : undefined => true)
    options.serveIndex = options.serveIndex || options.serveIndex === undefined;

    const shouldHandleServeIndex = contentBase && options.serveIndex;

    if (shouldHandleServeIndex) {
      defaultFeatures.push('contentBaseIndex');
    }

) {
defaultFeatures.push('contentBaseIndex');
}
Expand Down