Skip to content

Commit

Permalink
Serve folder's index when requesting folder without slash (#9066)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored Jun 8, 2023
1 parent 4db35cd commit f7fedaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe('server', function () {
assert.equal(await get('/', port), rootIndex);
assert.equal(await get('/something', port), rootIndex);
assert.equal(await get('/other', port), other);
assert.equal(await get('/foo', port), rootIndex);
assert.equal(await get('/foo', port), fooIndex);
assert.equal(await get('/foo/', port), fooIndex);
assert.equal(await get('/foo/bar', port), fooIndex);
assert.equal(await get('/foo/other', port), fooOther);
Expand Down
7 changes: 5 additions & 2 deletions packages/reporters/dev-server/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,11 @@ export default class Server {
let isIndex = withoutExtension === 'index';

let matchesIsIndex = null;
if (isIndex && req.url.startsWith(bundleDirSubdir)) {
// bundle is /bar/index.html and something inside of /bar/** was requested
if (
isIndex &&
(req.url.startsWith(bundleDirSubdir) || req.url === bundleDir)
) {
// bundle is /bar/index.html and (/bar or something inside of /bar/** was requested was requested)
matchesIsIndex = true;
} else if (req.url == path.posix.join(bundleDir, withoutExtension)) {
// bundle is /bar/foo.html and /bar/foo was requested
Expand Down

0 comments on commit f7fedaf

Please sign in to comment.