Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to form-data RC4 and pass null values to it #2208

Merged
merged 1 commit into from May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"combined-stream": "~1.0.5",
"extend": "~3.0.0",
"forever-agent": "~0.6.1",
"form-data": "~1.0.0-rc3",
"form-data": "~1.0.0-rc4",
"har-validator": "~2.0.6",
"hawk": "~3.1.3",
"http-signature": "~1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion request.js
Expand Up @@ -336,7 +336,7 @@ Request.prototype.init = function (options) {
var formData = options.formData
var requestForm = self.form()
var appendFormValue = function (key, value) {
if (value.hasOwnProperty('value') && value.hasOwnProperty('options')) {
if (value && value.hasOwnProperty('value') && value.hasOwnProperty('options')) {
requestForm.append(key, value.value, value.options)
} else {
requestForm.append(key, value)
Expand Down
14 changes: 14 additions & 0 deletions tests/test-form-data-error.js
Expand Up @@ -65,6 +65,20 @@ tape('omit content-length header if the value is set to NaN', function(t) {
})
})

// TODO: remove this test after form-data@2.0 starts stringifying null values
tape('form-data should throw on null value', function (t) {
t.throws(function () {
request({
method: 'POST',
url: 'http://localhost:6767',
formData: {
key: null
}
})
}, /Cannot read property 'path' of null/)
t.end()
})

tape('cleanup', function(t) {
s.close(function() {
t.end()
Expand Down