File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ export class Encoder {
6565 *
6666 * const encoder = new Encoder(fd)
6767 */
68- constructor ( form : FormDataLike , boundary : string = createBoundary ( 8 ) ) {
68+ constructor ( form : FormDataLike , boundary : string = createBoundary ( 16 ) ) {
6969 if ( ! isFormData ( form ) ) {
7070 throw new TypeError ( "Expected first argument to be a FormData instance." )
7171 }
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ export * from "./Encoder"
44
55export { default as isFileLike } from "./util/isFile"
66export { default as isFormDataLike } from "./util/isFormData"
7+ export { default as createBoundary } from "./util/createBoundary"
Original file line number Diff line number Diff line change 1- import { randomBytes } from "crypto"
1+ const alphabet
2+ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
23
34/**
45 * Generates a boundary string for FormData encoder.
56 */
6- const createBoundary = ( size : number ) : string => (
7- randomBytes ( size ) . toString ( "hex" )
8- )
7+ function createBoundary ( size : number ) : string {
8+ let res = ""
9+
10+ while ( size -- ) {
11+ res += alphabet [ Math . floor ( Math . random ( ) * alphabet . length ) ]
12+ }
13+
14+ return res
15+ }
916
1017export default createBoundary
You can’t perform that action at this time.
0 commit comments