From 214e0bc6e42fd52485d3afb6556e55504259c2b6 Mon Sep 17 00:00:00 2001 From: Sidhartha Chatterjee Date: Wed, 30 Jan 2019 02:55:11 +0530 Subject: [PATCH 1/2] Add tests asserting if nested directories with dots in their names work --- test/tests/server.js | 16 ++++++++++++++++ test/tests/util.js | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/test/tests/server.js b/test/tests/server.js index 0babd86f4..bcb6d5e3a 100644 --- a/test/tests/server.js +++ b/test/tests/server.js @@ -51,6 +51,14 @@ describe('Server', () => { listen = listenShorthand(done); // Hack to add a mock HMR json file to the in-memory filesystem. instance.fileSystem.writeFileSync('/123a123412.hot-update.json', '["hi"]'); + + // Add a nested directory and index.html inside + instance.fileSystem.mkdirSync("/reference"); + instance.fileSystem.mkdirSync("/reference/mono-v6.x.x"); + instance.fileSystem.writeFileSync( + "/reference/mono-v6.x.x/index.html", + "My Index." + ); }); after(close); @@ -103,6 +111,14 @@ describe('Server', () => { .expect(200, /My Index\./, done); }); + it("request to subdirectory without trailing slash", done => { + request(app) + .get("/public/reference/mono-v6.x.x") + .expect('Content-Type', 'text/html; charset=UTF-8') + .expect('Content-Length', '9') + .expect(200, /My Index\./, done); + }); + it('invalid range header', (done) => { request(app).get('/public/svg.svg') .set('Range', 'bytes=6000-') diff --git a/test/tests/util.js b/test/tests/util.js index 0a0b4f92b..d0528009f 100644 --- a/test/tests/util.js +++ b/test/tests/util.js @@ -268,7 +268,13 @@ describe('GetFilenameFromUrl', () => { outputPath: '/test/#leadinghash', publicPath: '/', expected: '/test/#leadinghash/test/sample.txt' - } + }, + { + url: '/folder-name-with-dots/mono-v6.x.x', + outputPath: '/', + publicPath: '/', + expected: '/folder-name-with-dots/mono-v6.x.x' + }, ]; for (const test of tests) { From c93784f7f1f91cefa0f693f8ee9a0ea9bad075d5 Mon Sep 17 00:00:00 2001 From: Sidhartha Chatterjee Date: Wed, 30 Jan 2019 02:58:41 +0530 Subject: [PATCH 2/2] Fix linter issues --- test/tests/server.js | 12 ++++++------ test/tests/util.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/tests/server.js b/test/tests/server.js index bcb6d5e3a..5a94344ab 100644 --- a/test/tests/server.js +++ b/test/tests/server.js @@ -53,11 +53,11 @@ describe('Server', () => { instance.fileSystem.writeFileSync('/123a123412.hot-update.json', '["hi"]'); // Add a nested directory and index.html inside - instance.fileSystem.mkdirSync("/reference"); - instance.fileSystem.mkdirSync("/reference/mono-v6.x.x"); + instance.fileSystem.mkdirSync('/reference'); + instance.fileSystem.mkdirSync('/reference/mono-v6.x.x'); instance.fileSystem.writeFileSync( - "/reference/mono-v6.x.x/index.html", - "My Index." + '/reference/mono-v6.x.x/index.html', + 'My Index.' ); }); @@ -111,9 +111,9 @@ describe('Server', () => { .expect(200, /My Index\./, done); }); - it("request to subdirectory without trailing slash", done => { + it('request to subdirectory without trailing slash', (done) => { request(app) - .get("/public/reference/mono-v6.x.x") + .get('/public/reference/mono-v6.x.x') .expect('Content-Type', 'text/html; charset=UTF-8') .expect('Content-Length', '9') .expect(200, /My Index\./, done); diff --git a/test/tests/util.js b/test/tests/util.js index d0528009f..476b4d83a 100644 --- a/test/tests/util.js +++ b/test/tests/util.js @@ -274,7 +274,7 @@ describe('GetFilenameFromUrl', () => { outputPath: '/', publicPath: '/', expected: '/folder-name-with-dots/mono-v6.x.x' - }, + } ]; for (const test of tests) {