ming_node 2.9.5 → 2.9.6

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.
Files changed (2) hide show
  1. package/index.js +8 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * By : Minglie
4
4
  * QQ: 934031452
5
5
  * Date :2021.12.01
6
- * version :2.9.5
6
+ * version :2.9.6
7
7
  */
8
8
  var http = require('http');
9
9
  var https = require('https');
@@ -109,7 +109,7 @@ M.get = function (url, callback, data, headers) {
109
109
  if (typeof callback == "function") {
110
110
 
111
111
  } else {
112
- headers = data || {};
112
+ headers = data || {'Content-Type': 'application/json'};
113
113
  data = callback;
114
114
  callback = () => {
115
115
  };
@@ -175,7 +175,11 @@ M.get = function (url, callback, data, headers) {
175
175
  res.on('end', function () {
176
176
  callback(html, res);
177
177
  try {
178
- html = JSON.parse(html)
178
+ if(headers && headers['Content-Type']=='application/json'){
179
+ html = JSON.parse(html)
180
+ }else {
181
+ html = html;
182
+ }
179
183
  } catch (e) {
180
184
  html = html;
181
185
  }
@@ -1985,8 +1989,6 @@ M.server = function () {
1985
1989
  console.log("listen on port:" + port);
1986
1990
  return server;
1987
1991
  }
1988
-
1989
- global.app=app;
1990
1992
  return app;
1991
1993
  }
1992
1994
  M["_gloable_exception_handle"]=(err)=>{
@@ -2833,7 +2835,7 @@ M.getRemoteCacheByUrl = async function (url) {
2833
2835
  if (url.startsWith("file:")) {
2834
2836
  text = M.readFile(url.substring(5));
2835
2837
  } else {
2836
- text = await M.get(url);
2838
+ text = await M.get(url,{},{});
2837
2839
  }
2838
2840
  console.log("req remote url:", url);
2839
2841
  M._globle_cacheMap[url] = text;
package/package.json CHANGED
@@ -46,5 +46,5 @@
46
46
  "scripts": {
47
47
  "test": "echo \"Error: no test specified\" && exit 1"
48
48
  },
49
- "version": "2.9.5"
49
+ "version": "2.9.6"
50
50
  }