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 @@ -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${ `${ Math . floor ( Math . random ( ) * 1e11 ) } ` . padStart ( 11 , '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> */
You can’t perform that action at this time.
0 commit comments