@zwa73/utils 1.0.178 → 1.0.179

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/dist/UtilCom.js CHANGED
@@ -30,7 +30,6 @@ var UtilCom;
30
30
  res.setTimeout(timeLimit, () => {
31
31
  UtilLogger_1.SLogger.warn(`${flagName} 接收反馈超时(timeLimit): ${timeLimit} ms`);
32
32
  resolve(undefined);
33
- return;
34
33
  });
35
34
  }
36
35
  let mergedata = initData;
@@ -39,7 +38,6 @@ var UtilCom;
39
38
  res.on('error', (e) => {
40
39
  UtilLogger_1.SLogger.warn(`${flagName} 接收反馈错误:${e}`);
41
40
  resolve(undefined);
42
- return;
43
41
  });
44
42
  res.on('end', () => {
45
43
  resolve({
@@ -86,8 +84,14 @@ var UtilCom;
86
84
  async function jsonReq(comReqOpt, reqData) {
87
85
  const { method } = comReqOpt;
88
86
  const isPost = (method == "POST");
89
- if (!isPost && reqData != undefined)
90
- comReqOpt.path += querystring_1.default.stringify(reqData);
87
+ if (!isPost && reqData != undefined) {
88
+ const queryString = querystring_1.default.stringify(reqData);
89
+ if (queryString) {
90
+ // 检查当前路径是否已经包含问号
91
+ const separator = comReqOpt.path.includes('?') ? '&' : '?';
92
+ comReqOpt.path += separator + queryString;
93
+ }
94
+ }
91
95
  const procReq = (req) => {
92
96
  if (isPost)
93
97
  req.write(JSON.stringify(reqData));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.178",
3
+ "version": "1.0.179",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/UtilCom.ts CHANGED
@@ -80,7 +80,6 @@ export async function comReq<T>(
80
80
  res.setTimeout(timeLimit!, ()=>{
81
81
  SLogger.warn(`${flagName} 接收反馈超时(timeLimit): ${timeLimit} ms`);
82
82
  resolve(undefined);
83
- return;
84
83
  });
85
84
  }
86
85
 
@@ -91,7 +90,6 @@ export async function comReq<T>(
91
90
  res.on('error',(e)=>{
92
91
  SLogger.warn(`${flagName} 接收反馈错误:${e}`);
93
92
  resolve(undefined);
94
- return;
95
93
  });
96
94
 
97
95
  res.on('end',()=>{
@@ -145,7 +143,14 @@ async function jsonReq<T extends ComReqOpt>(
145
143
  const {method} = comReqOpt;
146
144
  const isPost = (method=="POST");
147
145
 
148
- if(!isPost && reqData!=undefined) comReqOpt.path+=qs.stringify(reqData as GetReqData);
146
+ if (!isPost && reqData != undefined) {
147
+ const queryString = qs.stringify(reqData as GetReqData);
148
+ if (queryString) {
149
+ // 检查当前路径是否已经包含问号
150
+ const separator = comReqOpt.path.includes('?') ? '&' : '?';
151
+ comReqOpt.path += separator + queryString;
152
+ }
153
+ }
149
154
 
150
155
  const procReq = (req:http.ClientRequest)=>{
151
156
  if(isPost) req.write(JSON.stringify(reqData));