undici 7.2.2 → 7.2.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/web/fetch/body.js +9 -1
- package/package.json +1 -1
package/lib/web/fetch/body.js
CHANGED
|
@@ -17,6 +17,14 @@ const { isErrored, isDisturbed } = require('node:stream')
|
|
|
17
17
|
const { isArrayBuffer } = require('node:util/types')
|
|
18
18
|
const { serializeAMimeType } = require('./data-url')
|
|
19
19
|
const { multipartFormDataParser } = require('./formdata-parser')
|
|
20
|
+
let random
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const crypto = require('node:crypto')
|
|
24
|
+
random = (max) => crypto.randomInt(0, max)
|
|
25
|
+
} catch {
|
|
26
|
+
random = (max) => Math.floor(Math.random(max))
|
|
27
|
+
}
|
|
20
28
|
|
|
21
29
|
const textEncoder = new TextEncoder()
|
|
22
30
|
function noop () {}
|
|
@@ -110,7 +118,7 @@ function extractBody (object, keepalive = false) {
|
|
|
110
118
|
// Set source to a copy of the bytes held by object.
|
|
111
119
|
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
|
112
120
|
} else if (webidl.is.FormData(object)) {
|
|
113
|
-
const boundary = `----formdata-undici-0${`${
|
|
121
|
+
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
|
|
114
122
|
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
|
115
123
|
|
|
116
124
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|