File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 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')
1717const { isArrayBuffer } = require ( 'node:util/types' )
1818const { serializeAMimeType } = require ( './data-url' )
1919const { 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+ }
2028
2129const textEncoder = new TextEncoder ( )
2230function noop ( ) { }
@@ -110,7 +118,7 @@ function extractBody (object, keepalive = false) {
110118 // Set source to a copy of the bytes held by object.
111119 source = new Uint8Array ( object . buffer . slice ( object . byteOffset , object . byteOffset + object . byteLength ) )
112120 } 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' ) } `
114122 const prefix = `--${ boundary } \r\nContent-Disposition: form-data`
115123
116124 /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
You can’t perform that action at this time.
0 commit comments