diff --git a/packages/xarc-app-dev/lib/dev-admin/cdn-mock.js b/packages/xarc-app-dev/lib/dev-admin/cdn-mock.js index d58687efe..ec36fefd5 100644 --- a/packages/xarc-app-dev/lib/dev-admin/cdn-mock.js +++ b/packages/xarc-app-dev/lib/dev-admin/cdn-mock.js @@ -57,7 +57,7 @@ const cdnMock = { asset = LOADED_ASSETS[filePath] = Fs.readFileSync(fp); } const ext = Path.extname(filePath); - const mimeType = mime.lookup(ext); + const mimeType = mime.getType(ext); res.writeHead(200, { "Content-Type": mimeType, "Content-Length": Buffer.byteLength(asset) diff --git a/packages/xarc-app-dev/lib/dev-admin/dev-express.js b/packages/xarc-app-dev/lib/dev-admin/dev-express.js index af216f550..4fabc8d47 100644 --- a/packages/xarc-app-dev/lib/dev-admin/dev-express.js +++ b/packages/xarc-app-dev/lib/dev-admin/dev-express.js @@ -37,10 +37,9 @@ function setup(app, protocol, port) { replyNotFound: () => res.status(404).send("Not Found"), replyError: err => res.status(500).send(err), replyStaticData: data => { - const type = mime.lookup(req.url); + const type = mime.getType(req.url); if (type) { - const charset = mime.charsets.lookup(type); - res.set("Content-Type", type + (charset ? `; charset=${charset}` : "")); + res.set("Content-Type", type); } res.status(200).send(data); }, diff --git a/packages/xarc-app-dev/lib/dev-admin/dev-fastify.js b/packages/xarc-app-dev/lib/dev-admin/dev-fastify.js index da150c933..89d2ae823 100644 --- a/packages/xarc-app-dev/lib/dev-admin/dev-fastify.js +++ b/packages/xarc-app-dev/lib/dev-admin/dev-fastify.js @@ -44,10 +44,9 @@ async function register(fastify) { reply.send(err); }, replyStaticData: data => { - const type = mime.lookup(request.url); + const type = mime.getType(request.url); if (type) { - const charset = mime.charsets.lookup(type); - reply.header("Content-Type", type + (charset ? `; charset=${charset}` : "")); + reply.header("Content-Type", type); } reply.code(200).send(data); }, @@ -59,10 +58,9 @@ async function register(fastify) { reply.code(404); return; } - const type = mime.lookup(name); + const type = mime.getType(name); if (type) { - const charset = mime.charsets.lookup(type); - reply.header("Content-Type", type + (charset ? `; charset=${charset}` : "")); + reply.header("Content-Type", type); } reply.code(200).send(data); } diff --git a/packages/xarc-app-dev/lib/dev-admin/dev-hapi.js b/packages/xarc-app-dev/lib/dev-admin/dev-hapi.js index dd9562a87..2177dce41 100644 --- a/packages/xarc-app-dev/lib/dev-admin/dev-hapi.js +++ b/packages/xarc-app-dev/lib/dev-admin/dev-hapi.js @@ -45,11 +45,10 @@ function register(server, options, next) { }, replyError: err => reply(err), replyStaticData: data => { - const type = mime.lookup(req.url); + const type = mime.getType(req.url); const resp = reply.response(data).code(200); if (type) { - const charset = mime.charsets.lookup(type); - return resp.header("Content-Type", type + (charset ? `; charset=${charset}` : "")); + return resp.header("Content-Type", type); } return resp; }, @@ -60,11 +59,10 @@ function register(server, options, next) { } catch (e) { return reply.code(404); } - const type = mime.lookup(name); + const type = mime.getType(name); const resp = reply.response(data).code(200); if (type) { - const charset = mime.charsets.lookup(type); - resp.header("Content-Type", type + (charset ? `; charset=${charset}` : "")); + resp.header("Content-Type", type); } return resp; } diff --git a/packages/xarc-app-dev/lib/dev-admin/dev-hapi17.js b/packages/xarc-app-dev/lib/dev-admin/dev-hapi17.js index 3c29ef19a..063fb4c9c 100644 --- a/packages/xarc-app-dev/lib/dev-admin/dev-hapi17.js +++ b/packages/xarc-app-dev/lib/dev-admin/dev-hapi17.js @@ -47,11 +47,10 @@ function register(server) { return h.response(err); }, replyStaticData: data => { - const type = mime.lookup(req.url); + const type = mime.getType(req.url); const resp = h.response(data).code(200); if (type) { - const charset = mime.charsets.lookup(type); - resp.header("Content-Type", type + (charset ? `; charset=${charset}` : "")); + resp.header("Content-Type", type); } return resp.takeover(); }, @@ -62,11 +61,10 @@ function register(server) { } catch (e) { return h.code(404); } - const type = mime.lookup(name); + const type = mime.getType(name); const resp = h.response(data).code(200); if (type) { - const charset = mime.charsets.lookup(type); - resp.header("Content-Type", type + (charset ? `; charset=${charset}` : "")); + resp.header("Content-Type", type); } return resp.takeover(); } diff --git a/packages/xarc-app-dev/lib/dev-admin/dev-koa.js b/packages/xarc-app-dev/lib/dev-admin/dev-koa.js index 291ffbde1..3d4140c19 100644 --- a/packages/xarc-app-dev/lib/dev-admin/dev-koa.js +++ b/packages/xarc-app-dev/lib/dev-admin/dev-koa.js @@ -48,10 +48,9 @@ function setup(app, protocol, port) { return res; }, replyStaticData: data => { - const type = mime.lookup(req.url); + const type = mime.getType(req.url); if (type) { - const charset = mime.charsets.lookup(type); - res.append("Content-Type", type + (charset ? `; charset=${charset}` : "")); + res.append("Content-Type", type); } res.status = 200; res.body = data; diff --git a/packages/xarc-app-dev/package.json b/packages/xarc-app-dev/package.json index efac07a9c..c0291a06e 100644 --- a/packages/xarc-app-dev/package.json +++ b/packages/xarc-app-dev/package.json @@ -66,7 +66,7 @@ "isomorphic-loader": "^3.1.0", "lodash": "^4.13.1", "log-update": "^4.0.0", - "mime": "^1.6.0", + "mime": "^2.4.5", "mkdirp": "^0.5.1", "nix-clap": "^1.3.7", "nyc": "^14.1.1", @@ -120,7 +120,6 @@ }, "fyn": { "dependencies": { - "@jchip/redbird": "../../../redbird", "@xarc/webpack": "../xarc-webpack", "electrode-node-resolver": "../electrode-node-resolver", "subapp-util": "../subapp-util" diff --git a/packages/xarc-app-dev/test/spec/dev-admin/dev-fastify.spec.js b/packages/xarc-app-dev/test/spec/dev-admin/dev-fastify.spec.js index d06b8f0bd..874dc2d16 100644 --- a/packages/xarc-app-dev/test/spec/dev-admin/dev-fastify.spec.js +++ b/packages/xarc-app-dev/test/spec/dev-admin/dev-fastify.spec.js @@ -186,7 +186,7 @@ describe("dev-admin-fastify", function() { expect(reply.statusCode).eq(200); expect(reply.savedHeaders[0]).deep.eq({ name: "Content-Type", - value: "text/plain; charset=UTF-8" + value: "text/plain" }); expect(reply.savedPayloads.length).eq(1); expect(reply.savedPayloads[0].toString()).eq("blah"); diff --git a/packages/xarc-app-dev/test/spec/dev-hapi.spec.js b/packages/xarc-app-dev/test/spec/dev-hapi.spec.js index 1c6ec4a31..13013d2bf 100644 --- a/packages/xarc-app-dev/test/spec/dev-hapi.spec.js +++ b/packages/xarc-app-dev/test/spec/dev-hapi.spec.js @@ -77,7 +77,7 @@ describe("dev-hapi", function() { const { result } = cycle.replyFile("./xclap.js"); expect(result.code).to.equal(200); expect(result).to.have.any.keys("response"); - expect(result.headers["Content-Type"]).to.equal("application/javascript; charset=UTF-8"); + expect(result.headers["Content-Type"]).to.equal("application/javascript"); }); }); @@ -96,7 +96,7 @@ describe("dev-hapi", function() { expect(result.code).to.equal(200); expect(result.takeover).to.equal(true); expect(result).to.have.any.keys("response"); - expect(result.headers["Content-Type"]).to.equal("application/javascript; charset=UTF-8"); + expect(result.headers["Content-Type"]).to.equal("application/javascript"); }); }); @@ -115,7 +115,7 @@ describe("dev-hapi", function() { expect(result.code).to.equal(200); expect(result.takeover).to.equal(true); expect(result).to.have.any.keys("response"); - expect(result.headers["Content-Type"]).to.equal("application/javascript; charset=UTF-8"); + expect(result.headers["Content-Type"]).to.equal("application/javascript"); }); });