Skip to content

Commit c64a2c1

Browse files
sidharthachatterjeeevilebottnawi
authored andcommitted
test: add tests to assert if subdirectories with special characters are served correctly (#365)
1 parent 71c3e20 commit c64a2c1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

test/tests/server.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ describe('Server', () => {
5151
listen = listenShorthand(done);
5252
// Hack to add a mock HMR json file to the in-memory filesystem.
5353
instance.fileSystem.writeFileSync('/123a123412.hot-update.json', '["hi"]');
54+
55+
// Add a nested directory and index.html inside
56+
instance.fileSystem.mkdirSync('/reference');
57+
instance.fileSystem.mkdirSync('/reference/mono-v6.x.x');
58+
instance.fileSystem.writeFileSync(
59+
'/reference/mono-v6.x.x/index.html',
60+
'My Index.'
61+
);
5462
});
5563

5664
after(close);
@@ -103,6 +111,14 @@ describe('Server', () => {
103111
.expect(200, /My Index\./, done);
104112
});
105113

114+
it('request to subdirectory without trailing slash', (done) => {
115+
request(app)
116+
.get('/public/reference/mono-v6.x.x')
117+
.expect('Content-Type', 'text/html; charset=UTF-8')
118+
.expect('Content-Length', '9')
119+
.expect(200, /My Index\./, done);
120+
});
121+
106122
it('invalid range header', (done) => {
107123
request(app).get('/public/svg.svg')
108124
.set('Range', 'bytes=6000-')

test/tests/util.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ describe('GetFilenameFromUrl', () => {
268268
outputPath: '/test/#leadinghash',
269269
publicPath: '/',
270270
expected: '/test/#leadinghash/test/sample.txt'
271+
},
272+
{
273+
url: '/folder-name-with-dots/mono-v6.x.x',
274+
outputPath: '/',
275+
publicPath: '/',
276+
expected: '/folder-name-with-dots/mono-v6.x.x'
271277
}
272278
];
273279

0 commit comments

Comments
 (0)