@nxtedition/lib 15.0.33 → 15.0.34
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/undici/index.js +8 -2
- package/package.json +1 -1
package/lib/undici/index.js
CHANGED
|
@@ -77,15 +77,21 @@ const dispatchers = {
|
|
|
77
77
|
cache: require('./interceptor/cache.js'),
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
async function request(url, opts
|
|
80
|
+
async function request(url, opts) {
|
|
81
81
|
if (typeof url === 'string') {
|
|
82
82
|
url = new URL(url)
|
|
83
83
|
} else if (url instanceof URL) {
|
|
84
84
|
// Do nothing...
|
|
85
|
+
} else if (typeof url.origin === 'string' && typeof (url.path ?? url.pathname) === 'string') {
|
|
86
|
+
// Do nothing...
|
|
85
87
|
} else {
|
|
86
88
|
throw new Error('missing url')
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
if (opts == null && typeof url === 'object' && url != null) {
|
|
92
|
+
opts = url
|
|
93
|
+
}
|
|
94
|
+
|
|
89
95
|
const method = opts.method ?? (opts.body ? 'POST' : 'GET')
|
|
90
96
|
const idempotent = opts.idempotent ?? (method === 'GET' || method === 'HEAD')
|
|
91
97
|
|
|
@@ -117,7 +123,7 @@ async function request(url, opts = {}) {
|
|
|
117
123
|
...headers,
|
|
118
124
|
},
|
|
119
125
|
origin: url.origin,
|
|
120
|
-
path: url.search ? `${url.pathname}${url.search ?? ''}` : url.pathname,
|
|
126
|
+
path: url.path ? url.path : url.search ? `${url.pathname}${url.search ?? ''}` : url.pathname,
|
|
121
127
|
reset: opts.reset ?? false,
|
|
122
128
|
headersTimeout: opts.headersTimeout,
|
|
123
129
|
bodyTimeout: opts.bodyTimeout,
|