cvitool 1.0.785 → 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 +5 -1
- package/build/src/hgo.js +20 -4
- package/package.json +1 -1
- package/src/hgo.ts +20 -4
package/CHANGELOG.md
CHANGED
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/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
|
});
|