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 @@ -22,6 +22,14 @@ const { isUint8Array, isArrayBuffer } = require('util/types')
2222const { File : UndiciFile } = require ( './file' )
2323const { parseMIMEType, serializeAMimeType } = require ( './dataURL' )
2424
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+
2533let ReadableStream = globalThis . ReadableStream
2634
2735/** @type {globalThis['File'] } */
@@ -107,7 +115,7 @@ function extractBody (object, keepalive = false) {
107115 // Set source to a copy of the bytes held by object.
108116 source = new Uint8Array ( object . buffer . slice ( object . byteOffset , object . byteOffset + object . byteLength ) )
109117 } 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' ) } `
111119 const prefix = `--${ boundary } \r\nContent-Disposition: form-data`
112120
113121 /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
You can’t perform that action at this time.
0 commit comments