Skip to content

Commit bd94941

Browse files
committed
Use fixed size for boundary string, because createBoundary function is private.
1 parent d86e80a commit bd94941

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

lib/Encoder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class FormDataEncoder {
6666
*
6767
* const encoder = new Encoder(fd)
6868
*/
69-
constructor(form: FormDataLike, boundary: string = createBoundary(16)) {
69+
constructor(form: FormDataLike, boundary: string = createBoundary()) {
7070
if (!isFormData(form)) {
7171
throw new TypeError("Expected first argument to be a FormData instance.")
7272
}

lib/util/createBoundary.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@ import test from "ava"
33
import createBoundary from "./createBoundary"
44

55
test("Returns a string", t => {
6-
const actual = createBoundary(16)
6+
const actual = createBoundary()
77

88
t.is(typeof actual, "string")
99
})
1010

11-
test("Returns a string of given length", t => {
12-
const expected = 24
13-
const actual = createBoundary(expected)
14-
15-
t.is(actual.length, expected)
16-
})
17-
1811
test("Returns a string that passes regex of valid range", t => {
19-
const actual = createBoundary(16)
12+
const actual = createBoundary()
2013

2114
t.regex(actual, /^[a-zA-Z0-9'_-]+$/)
2215
})

lib/util/createBoundary.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ const alphabet
33

44
/**
55
* Generates a boundary string for FormData encoder.
6-
*
7-
* @param size The size of the resulting string
86
*/
9-
function createBoundary(size: number): string {
7+
function createBoundary(): string {
8+
let size = 16
109
let res = ""
1110

1211
while (size--) {

0 commit comments

Comments
 (0)