@nxtedition/nxt-undici 3.0.1 → 3.0.3

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 CHANGED
@@ -16,6 +16,8 @@ export const interceptors = {
16
16
  dns: (await import('./interceptor/dns.js')).default,
17
17
  }
18
18
 
19
+ export { parseHeaders } from './utils.js'
20
+
19
21
  export async function request(url, opts) {
20
22
  // TODO (fix): More argument validation...
21
23
 
@@ -71,6 +73,7 @@ export async function request(url, opts) {
71
73
  }
72
74
 
73
75
  return await undici.request(url, {
76
+ id: opts.id,
74
77
  method,
75
78
  dispatcher,
76
79
  body: opts.body,
@@ -12,8 +12,17 @@ function genReqId() {
12
12
  }
13
13
 
14
14
  export default (opts) => (dispatch) => (opts, handler) => {
15
- let id = opts.headers?.['request-id']
16
- id = id ? `${id},${genReqId()}` : genReqId()
15
+ let id
16
+
17
+ if (opts.headers?.['request-id']) {
18
+ id = opts.headers['request-id']
19
+ }
20
+
21
+ if (opts.id) {
22
+ id = id && id !== opts.id ? id + ',' + opts.id : opts.id
23
+ }
24
+
25
+ id = id ? id + ',' + opts.id : genReqId()
17
26
 
18
27
  return dispatch(
19
28
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",