Skip to content

Commit cf4d7a9

Browse files
clshortfuseevilebottnawi
authored andcommitted
fix(middleware): do not add 'null' to Content-Type (#355)
1 parent e6cfe7c commit cf4d7a9

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/middleware.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = function wrapper(context) {
6969
let content = context.fs.readFileSync(filename);
7070
content = handleRangeHeaders(content, req, res);
7171

72-
let contentType = mime.getType(filename);
72+
let contentType = mime.getType(filename) || '';
7373

7474
// do not add charset to WebAssembly files, otherwise compileStreaming will fail in the client
7575
if (!/\.wasm$/.test(filename)) {

test/tests/server.js

+23
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,29 @@ describe('Server', () => {
219219
});
220220
});
221221

222+
describe('no extension support', () => {
223+
before((done) => {
224+
app = express();
225+
const compiler = webpack(webpackConfig);
226+
instance = middleware(compiler, {
227+
stats: 'errors-only',
228+
logLevel,
229+
index: 'noextension'
230+
});
231+
app.use(instance);
232+
listen = listenShorthand(done);
233+
instance.fileSystem.writeFileSync('/noextension', 'hello');
234+
});
235+
after(close);
236+
237+
it('request to noextension', (done) => {
238+
request(app).get('/')
239+
.expect('hello')
240+
.expect('Content-Type', '; charset=UTF-8')
241+
.expect(200, done);
242+
});
243+
});
244+
222245
describe('custom mimeTypes', () => {
223246
before((done) => {
224247
app = express();

0 commit comments

Comments
 (0)