Skip to content

Commit

Permalink
fix(middleware): do not add 'null' to Content-Type
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Jan 1, 2019
1 parent e6cfe7c commit dc9aa4e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/middleware.js
Expand Up @@ -69,7 +69,7 @@ module.exports = function wrapper(context) {
let content = context.fs.readFileSync(filename);
content = handleRangeHeaders(content, req, res);

let contentType = mime.getType(filename);
let contentType = mime.getType(filename) || '';

// do not add charset to WebAssembly files, otherwise compileStreaming will fail in the client
if (!/\.wasm$/.test(filename)) {
Expand Down
23 changes: 23 additions & 0 deletions test/tests/server.js
Expand Up @@ -219,6 +219,29 @@ describe('Server', () => {
});
});

describe('no extension support', () => {
before((done) => {
app = express();
const compiler = webpack(webpackConfig);
instance = middleware(compiler, {
stats: 'errors-only',
logLevel,
index: 'noextension'
});
app.use(instance);
listen = listenShorthand(done);
instance.fileSystem.writeFileSync('/noextension', 'hello');
});
after(close);

it('request to noextension', (done) => {
request(app).get('/')
.expect('hello')
.expect('Content-Type', '; charset=UTF-8')
.expect(200, done);
});
});

describe('custom mimeTypes', () => {
before((done) => {
app = express();
Expand Down

0 comments on commit dc9aa4e

Please sign in to comment.