Bugfix for application/wasm content-type being served with a charset value

This commit is contained in:
Jason Miller
2020-08-12 18:21:38 -04:00
parent 88a5295e21
commit 038f34b89a

15
.proxyrc.js Normal file
View File

@@ -0,0 +1,15 @@
module.exports = function(app) {
// `app` is an Express instance
app.use(function(req, res, next) {
const sh = res.setHeader;
res.setHeader = function(key, value) {
// remove pointless/incorrect charset from binary responses:
if (/^content-type$/i.test(key)) {
const m = value && value.match(/^(image\/|application\/wasm); charset=.+$/);
if (m) value = m[1];
}
return sh.call(this, key, value);
}
next();
});
};