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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class Server {
this.clientOverlay = options.overlay;
this.clientLogLevel = options.clientLogLevel;

this.serveIndex = options.serveIndex;

this.publicHost = options.public;
this.allowedHosts = options.allowedHosts;
this.disableHostCheck = !!options.disableHostCheck;
Expand Down Expand Up @@ -551,7 +553,10 @@ class Server {

defaultFeatures.push('magicHtml');

if (contentBase !== false) {
if (
contentBase !== false &&
(options.serveIndex || typeof 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.

Don't use typeof, we prefer using !

Copy link
Member Author

Choose a reason for hiding this comment

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

      (options.serveIndex || options.serveIndex === undefined)

@evilebottnawi done

) {
defaultFeatures.push('contentBaseIndex');
}
// compress is placed last and uses unshift so that it will be the first middleware used
Expand Down
3 changes: 3 additions & 0 deletions lib/options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"type": "object",
"properties": {
"serveIndex": {
"type": "boolean"
},
"hot": {
"type": "boolean"
},
Expand Down