File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ const { isUint8Array, isArrayBuffer } = require('util/types')
22
22
const { File : UndiciFile } = require ( './file' )
23
23
const { parseMIMEType, serializeAMimeType } = require ( './dataURL' )
24
24
25
+ let random
26
+ try {
27
+ const crypto = require ( 'node:crypto' )
28
+ random = ( max ) => crypto . randomInt ( 0 , max )
29
+ } catch {
30
+ random = ( max ) => Math . floor ( Math . random ( max ) )
31
+ }
32
+
25
33
let ReadableStream = globalThis . ReadableStream
26
34
27
35
/** @type {globalThis['File'] } */
@@ -107,7 +115,7 @@ function extractBody (object, keepalive = false) {
107
115
// Set source to a copy of the bytes held by object.
108
116
source = new Uint8Array ( object . buffer . slice ( object . byteOffset , object . byteOffset + object . byteLength ) )
109
117
} else if ( util . isFormDataLike ( object ) ) {
110
- const boundary = `----formdata-undici-0${ `${ Math . floor ( Math . random ( ) * 1e11 ) } ` . padStart ( 11 , '0' ) } `
118
+ const boundary = `----formdata-undici-0${ `${ random ( 1e11 ) } ` . padStart ( 11 , '0' ) } `
111
119
const prefix = `--${ boundary } \r\nContent-Disposition: form-data`
112
120
113
121
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
You can’t perform that action at this time.
0 commit comments