cvitool 1.0.784 → 1.0.786
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/CHANGELOG.md +9 -1
- package/build/src/cutil.js +1 -1
- package/build/src/hgo.js +20 -4
- package/package.json +1 -1
- package/src/cutil.ts +1 -1
- package/src/hgo.ts +20 -4
package/CHANGELOG.md
CHANGED
|
@@ -56,4 +56,12 @@
|
|
|
56
56
|
|
|
57
57
|
## [1.0.784] - 2025-12-03
|
|
58
58
|
### Fixed
|
|
59
|
-
- 修复checkURLResource函数请求发生CERT_HAS_EXPIRED时抛错问题
|
|
59
|
+
- 修复checkURLResource函数请求发生CERT_HAS_EXPIRED时抛错问题
|
|
60
|
+
|
|
61
|
+
## [1.0.785] - 2025-12-05
|
|
62
|
+
### Fixed
|
|
63
|
+
- 修复validate函数string类型传空格可以通过问题
|
|
64
|
+
|
|
65
|
+
## [1.0.786] - 2026-02-07
|
|
66
|
+
### Fixed
|
|
67
|
+
- 修复request重定向响应的location未携带域名导致后续请求失败问题
|
package/build/src/cutil.js
CHANGED
|
@@ -445,7 +445,7 @@ function validate(value, rule, finalFunc) {
|
|
|
445
445
|
result.pass = false;
|
|
446
446
|
return result;
|
|
447
447
|
}
|
|
448
|
-
if ((type === 'string' && !allowEmpty && fieldValue === '') ||
|
|
448
|
+
if ((type === 'string' && !allowEmpty && fieldValue.trim() === '') ||
|
|
449
449
|
(type === 'array' && !allowEmpty && fieldValue.length === 0) ||
|
|
450
450
|
(type === 'object' && !allowEmpty && Object.keys(fieldValue).length === 0)) {
|
|
451
451
|
result.message = 'field value can not empty';
|
package/build/src/hgo.js
CHANGED
|
@@ -66,7 +66,11 @@ function request(url, options) {
|
|
|
66
66
|
const req = reqProtocol.request(reqOpt, res => {
|
|
67
67
|
// 需要重定向的情况
|
|
68
68
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
69
|
-
|
|
69
|
+
let newUrl = res.headers.location;
|
|
70
|
+
if (!newUrl.startsWith('http')) {
|
|
71
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
72
|
+
}
|
|
73
|
+
resolve(request(newUrl, Object.assign(Object.assign({}, options), { originUrl: url })));
|
|
70
74
|
}
|
|
71
75
|
resHandld(res, resolve, reject, resType, method, readTimeOut, req, originUrl || url);
|
|
72
76
|
});
|
|
@@ -133,7 +137,11 @@ function reqSendBuffer(url, options) {
|
|
|
133
137
|
const req = reqProtocol.request(reqOpt, res => {
|
|
134
138
|
// 需要重定向的情况
|
|
135
139
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
136
|
-
|
|
140
|
+
let newUrl = res.headers.location;
|
|
141
|
+
if (!newUrl.startsWith('http')) {
|
|
142
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
143
|
+
}
|
|
144
|
+
resolve(request(newUrl, Object.assign(Object.assign({}, options), { originUrl: url })));
|
|
137
145
|
}
|
|
138
146
|
resHandld(res, resolve, reject, resType, method, readTimeOut, req, originUrl || url);
|
|
139
147
|
});
|
|
@@ -195,7 +203,11 @@ function reqSendStream(url, options) {
|
|
|
195
203
|
const req = reqProtocol.request(reqOpt, res => {
|
|
196
204
|
// 需要重定向的情况
|
|
197
205
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
198
|
-
|
|
206
|
+
let newUrl = res.headers.location;
|
|
207
|
+
if (!newUrl.startsWith('http')) {
|
|
208
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
209
|
+
}
|
|
210
|
+
resolve(request(newUrl, Object.assign(Object.assign({}, options), { originUrl: url })));
|
|
199
211
|
}
|
|
200
212
|
resHandld(res, resolve, reject, resType, method, readTimeOut, req, originUrl || url);
|
|
201
213
|
});
|
|
@@ -247,7 +259,11 @@ function reqSendMultiPart(url, options) {
|
|
|
247
259
|
const req = reqProtocol.request(reqOpt, res => {
|
|
248
260
|
// 需要重定向的情况
|
|
249
261
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
250
|
-
|
|
262
|
+
let newUrl = res.headers.location;
|
|
263
|
+
if (!newUrl.startsWith('http')) {
|
|
264
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
265
|
+
}
|
|
266
|
+
resolve(request(newUrl, Object.assign(Object.assign({}, options), { originUrl: url })));
|
|
251
267
|
}
|
|
252
268
|
resHandld(res, resolve, reject, resType, 'post', readTimeOut, req, originUrl || url);
|
|
253
269
|
});
|
package/package.json
CHANGED
package/src/cutil.ts
CHANGED
|
@@ -487,7 +487,7 @@ function validate(value: { [key: string]: any }, rule: { [key: string]: validate
|
|
|
487
487
|
return result;
|
|
488
488
|
}
|
|
489
489
|
if (
|
|
490
|
-
(type === 'string' && !allowEmpty && fieldValue === '') ||
|
|
490
|
+
(type === 'string' && !allowEmpty && (fieldValue as string).trim() === '') ||
|
|
491
491
|
(type === 'array' && !allowEmpty && (fieldValue as any[]).length === 0) ||
|
|
492
492
|
(type === 'object' && !allowEmpty && Object.keys(fieldValue).length === 0)
|
|
493
493
|
) {
|
package/src/hgo.ts
CHANGED
|
@@ -120,7 +120,11 @@ async function request(url: string, options?: reqOptions): Promise<ResData> {
|
|
|
120
120
|
const req = reqProtocol.request(reqOpt, res => {
|
|
121
121
|
// 需要重定向的情况
|
|
122
122
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
123
|
-
|
|
123
|
+
let newUrl = res.headers.location;
|
|
124
|
+
if (!newUrl.startsWith('http')) {
|
|
125
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
126
|
+
}
|
|
127
|
+
resolve(request(newUrl, { ...options, originUrl: url }));
|
|
124
128
|
}
|
|
125
129
|
resHandld(res, resolve, reject, resType, method, readTimeOut, req, originUrl || url);
|
|
126
130
|
});
|
|
@@ -187,7 +191,11 @@ async function reqSendBuffer(url: string, options: reqSendBufferOptions): Promis
|
|
|
187
191
|
const req = reqProtocol.request(reqOpt, res => {
|
|
188
192
|
// 需要重定向的情况
|
|
189
193
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
190
|
-
|
|
194
|
+
let newUrl = res.headers.location;
|
|
195
|
+
if (!newUrl.startsWith('http')) {
|
|
196
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
197
|
+
}
|
|
198
|
+
resolve(request(newUrl, { ...options, originUrl: url }));
|
|
191
199
|
}
|
|
192
200
|
resHandld(res, resolve, reject, resType, method, readTimeOut, req, originUrl || url);
|
|
193
201
|
});
|
|
@@ -250,7 +258,11 @@ async function reqSendStream(url: string, options: reqSendStreamOptions): Promis
|
|
|
250
258
|
const req = reqProtocol.request(reqOpt, res => {
|
|
251
259
|
// 需要重定向的情况
|
|
252
260
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
253
|
-
|
|
261
|
+
let newUrl = res.headers.location;
|
|
262
|
+
if (!newUrl.startsWith('http')) {
|
|
263
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
264
|
+
}
|
|
265
|
+
resolve(request(newUrl, { ...options, originUrl: url }));
|
|
254
266
|
}
|
|
255
267
|
resHandld(res, resolve, reject, resType, method, readTimeOut, req, originUrl || url);
|
|
256
268
|
});
|
|
@@ -307,7 +319,11 @@ async function reqSendMultiPart(url: string, options: reqSendMultiPartOptions):
|
|
|
307
319
|
const req = reqProtocol.request(reqOpt, res => {
|
|
308
320
|
// 需要重定向的情况
|
|
309
321
|
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
310
|
-
|
|
322
|
+
let newUrl = res.headers.location;
|
|
323
|
+
if (!newUrl.startsWith('http')) {
|
|
324
|
+
newUrl = new URL(originUrl || url).origin + res.headers.location;
|
|
325
|
+
}
|
|
326
|
+
resolve(request(newUrl, { ...options, originUrl: url }));
|
|
311
327
|
}
|
|
312
328
|
resHandld(res, resolve, reject, resType, 'post', readTimeOut, req, originUrl || url);
|
|
313
329
|
});
|