@less-is-more/less-js 1.4.32-2 → 1.4.32-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/router.js +7 -3
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -35,9 +35,13 @@ module.exports = class Router {
|
|
|
35
35
|
}
|
|
36
36
|
let res = {
|
|
37
37
|
content: "",
|
|
38
|
+
headers: {},
|
|
38
39
|
send: function (content) {
|
|
39
40
|
this.content = content;
|
|
40
41
|
},
|
|
42
|
+
setHeader: function (key, value) {
|
|
43
|
+
this.headers[key] = value;
|
|
44
|
+
},
|
|
41
45
|
};
|
|
42
46
|
// 转换后调用原来的方法
|
|
43
47
|
await this.route(targets, req, res, context);
|
|
@@ -213,13 +217,13 @@ module.exports = class Router {
|
|
|
213
217
|
req.headers["Accept-Encoding"] || req.headers["accept-encoding"];
|
|
214
218
|
if (acceptEncoding) {
|
|
215
219
|
if (acceptEncoding.includes("br")) {
|
|
216
|
-
content = zlib.brotliCompressSync(content)
|
|
220
|
+
content = zlib.brotliCompressSync(content);
|
|
217
221
|
res.setHeader("Content-Encoding", "br");
|
|
218
222
|
} else if (acceptEncoding.includes("gzip")) {
|
|
219
|
-
content = zlib.gzipSync(content)
|
|
223
|
+
content = zlib.gzipSync(content);
|
|
220
224
|
res.setHeader("Content-Encoding", "gzip");
|
|
221
225
|
} else if (acceptEncoding.includes("deflate")) {
|
|
222
|
-
content = zlib.deflateSync(content)
|
|
226
|
+
content = zlib.deflateSync(content);
|
|
223
227
|
res.setHeader("Content-Encoding", "deflate");
|
|
224
228
|
}
|
|
225
229
|
}
|