-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
alexander-akait
merged 12 commits into
webpack:master
from
EslamHiko:add-serve-index-option
Apr 5, 2019
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c3fc4a7
add option serveIndex
EslamHiko 325c5cb
setting the default option serveIndex value to be true
EslamHiko c3e4aca
add/remove contentBaseIndex feature to/from defaultFeatures using ser…
EslamHiko e426144
remove typeof and compare the option value directly with undefined
EslamHiko bee7cbc
add the option with the default value to options.js & simplifying the…
EslamHiko 88a9252
setting options.serveIndex to a seperate variable
EslamHiko 43337af
add Tests
EslamHiko f367fda
add Test case where you have a folder with index.html inside of it
EslamHiko bd56fdc
Merge branch 'master' into add-serve-index-option
evilebottnawi 4c33da3
add (folder with index.html inside it) test case to serveIndex:true &…
EslamHiko dd3bafe
Merge branch 'add-serve-index-option' of https://github.com/EslamHiko…
EslamHiko f29502f
Merge branch 'master' into add-serve-index-option
evilebottnawi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"serveIndex": { | ||
"type": "boolean" | ||
}, | ||
"hot": { | ||
"type": "boolean" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,89 @@ describe('ContentBase', () => { | |
}, 1000); | ||
}); | ||
}); | ||
describe('test listing files in folders without index.html using the option serveIndex:false', () => { | ||
beforeAll((done) => { | ||
server = helper.start( | ||
config, | ||
{ | ||
contentBase: contentBasePublic, | ||
watchContentBase: true, | ||
serveIndex: false, | ||
}, | ||
done | ||
); | ||
req = request(server.app); | ||
}); | ||
|
||
afterAll((done) => { | ||
helper.close(() => { | ||
done(); | ||
}); | ||
}); | ||
|
||
it("shouldn't list the files inside the assets folder (404)", (done) => { | ||
req.get('/assets/').expect(404, done); | ||
}); | ||
|
||
it('should show Heyo. because bar has index.html inside it (200)', (done) => { | ||
req.get('/bar/').expect(200, /Heyo/, done); | ||
}); | ||
}); | ||
describe('test listing files in folders without index.html using the option serveIndex:true', () => { | ||
beforeAll((done) => { | ||
server = helper.start( | ||
config, | ||
{ | ||
contentBase: contentBasePublic, | ||
watchContentBase: true, | ||
serveIndex: true, | ||
}, | ||
done | ||
); | ||
req = request(server.app); | ||
}); | ||
|
||
afterAll((done) => { | ||
helper.close(() => { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should list the files inside the assets folder (200)', (done) => { | ||
req.get('/assets/').expect(200, done); | ||
}); | ||
|
||
it('should show Heyo. because bar has index.html inside it (200)', (done) => { | ||
req.get('/bar/').expect(200, /Heyo/, done); | ||
}); | ||
}); | ||
describe('test listing files in folders without index.html using the option serveIndex default (true)', () => { | ||
beforeAll((done) => { | ||
server = helper.start( | ||
config, | ||
{ | ||
contentBase: contentBasePublic, | ||
watchContentBase: true, | ||
}, | ||
done | ||
); | ||
req = request(server.app); | ||
}); | ||
|
||
afterAll((done) => { | ||
helper.close(() => { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should list the files inside the assets folder (200)', (done) => { | ||
req.get('/assets/').expect(200, done); | ||
}); | ||
|
||
it('should show Heyo. because bar has index.html inside it (200)', (done) => { | ||
req.get('/bar/').expect(200, /Heyo/, done); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
describe('to directories', () => { | ||
beforeAll((done) => { | ||
server = helper.start( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Heyo |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the following test here because it is confirmed in
serveIndex:false
.