@nxtedition/nxt-undici 2.0.9 → 2.0.10
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/lib/interceptor/redirect.js +11 -5
- package/package.json +1 -1
|
@@ -33,13 +33,10 @@ class Handler {
|
|
|
33
33
|
return this.handler.onHeaders(statusCode, headers, resume, statusText)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (isDisturbed(this.opts.body)) {
|
|
37
|
-
throw new Error(`Disturbed request cannot be redirected.`)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
36
|
const location = findHeader(headers, 'location')
|
|
41
37
|
|
|
42
38
|
if (!location) {
|
|
39
|
+
// TODO (perf): Consume body?
|
|
43
40
|
throw new Error(`Missing redirection location .`)
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -52,12 +49,21 @@ class Handler {
|
|
|
52
49
|
} else {
|
|
53
50
|
const maxCount = Number.isFinite(this.opts.follow)
|
|
54
51
|
? this.opts.follow
|
|
55
|
-
: this.opts.follow?.count
|
|
52
|
+
: Number.isFinite(this.opts.follow?.count)
|
|
53
|
+
? this.opts.follow?.count
|
|
54
|
+
: 0
|
|
55
|
+
|
|
56
56
|
if (this.count >= maxCount) {
|
|
57
|
+
// TODO (perf): Consume body?
|
|
57
58
|
throw new Error(`Max redirections reached: ${maxCount}.`)
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
if (isDisturbed(this.opts.body)) {
|
|
63
|
+
// TODO (perf): Consume body?
|
|
64
|
+
throw new Error(`Disturbed request cannot be redirected.`)
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
const { origin, pathname, search } = parseURL(
|
|
62
68
|
new URL(location, this.opts.origin && new URL(this.opts.path, this.opts.origin)),
|
|
63
69
|
)
|