@nxtedition/nxt-undici 4.0.2 → 4.1.1
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/index.js +10 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -68,7 +68,15 @@ function wrapDispatcher(dispatcher) {
|
|
|
68
68
|
error: opts.error ?? true,
|
|
69
69
|
verify: opts.verify ?? true,
|
|
70
70
|
logger: opts.logger ?? null,
|
|
71
|
-
lookup:
|
|
71
|
+
lookup:
|
|
72
|
+
opts.lookup ??
|
|
73
|
+
((origin, opts, callback) =>
|
|
74
|
+
callback(
|
|
75
|
+
null,
|
|
76
|
+
Array.isArray(origin)
|
|
77
|
+
? origin[Math.floor(Math.random() * origin.length)]
|
|
78
|
+
: origin,
|
|
79
|
+
)),
|
|
72
80
|
dns: opts.dns ?? true,
|
|
73
81
|
},
|
|
74
82
|
handler,
|
|
@@ -95,7 +103,7 @@ export async function request(url, opts) {
|
|
|
95
103
|
} else if (url instanceof URL) {
|
|
96
104
|
opts = { url, ...opts }
|
|
97
105
|
} else if (typeof url.origin === 'string' && typeof (url.path ?? url.pathname) === 'string') {
|
|
98
|
-
opts = { url, ...opts }
|
|
106
|
+
opts = opts ? { ...url, ...opts } : url
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
if (opts == null && typeof url === 'object' && url != null) {
|