Skip to content

Commit

Permalink
🐛 Fix crash on nested null formdata value. #68
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Jan 25, 2020
1 parent e115c63 commit 9c1adf0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/bundle/wretch.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle/wretch.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle/wretch.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle/wretch.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/wretcher.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/wretcher.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/wretcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ function convertFormData(
!recursive.includes(key)
)
) {
convertFormData(value, recursive, formData, [...ancestors, key])
if(value !== null) {
convertFormData(value, recursive, formData, [...ancestors, key])
}
} else {
formData.append(formKey, value)
}
Expand Down
3 changes: 2 additions & 1 deletion test/node/wretch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ describe("Wretch", function () {
beak: {
color: "yellow"
},
nbOfLegs: 2
nbOfLegs: 2,
nullProp: null
}
}
let decoded = await wretch(`${_URL}/formData/decode`)
Expand Down

0 comments on commit 9c1adf0

Please sign in to comment.