diff --git a/lib/Server.js b/lib/Server.js index 239fe3783c..a403f4bbac 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -405,7 +405,7 @@ class Server { throw new Error('Watching remote files is not supported.'); } else if (Array.isArray(contentBase)) { contentBase.forEach((item) => { - if (isAbsoluteUrl(String(item))) { + if (isAbsoluteUrl(String(item)) || typeof item === 'number') { throw new Error('Watching remote files is not supported.'); } this._watch(item); diff --git a/test/server/contentBase-option.test.js b/test/server/contentBase-option.test.js index 3d6ab7de58..13acc53165 100644 --- a/test/server/contentBase-option.test.js +++ b/test/server/contentBase-option.test.js @@ -268,7 +268,7 @@ describe('contentBase option', () => { }); describe('testing single & multiple external paths', () => { - afterAll((done) => { + afterEach((done) => { testServer.close(() => { done(); }); @@ -301,6 +301,42 @@ describe('contentBase option', () => { done(); } }); + it('Should not throw exception (local path with lower case first character)', (done) => { + testServer.start( + config, + { + contentBase: + contentBasePublic.charAt(0).toLowerCase() + + contentBasePublic.substring(1), + watchContentBase: true, + port, + }, + done + ); + }); + it("Should not throw exception (local path with lower case first character & has '-')", (done) => { + testServer.start( + config, + { + contentBase: 'c:\\absolute\\path\\to\\content-base', + watchContentBase: true, + port, + }, + done + ); + }); + it("Should not throw exception (local path with upper case first character & has '-')", (done) => { + testServer.start( + config, + { + contentBase: 'C:\\absolute\\path\\to\\content-base', + watchContentBase: true, + port, + }, + done + ); + }); + it('Should throw exception (array)', (done) => { try { // eslint-disable-next-line no-unused-vars