json-form-data
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "json-form-data", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A library to convert javascript objects into form data.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,3 +11,4 @@ # json-form-data | ||
* Compatible with legacy web browsers | ||
* Works with primitive data types and File blobs | ||
* Supports all primitive data types | ||
* Supports File and FileList data types | ||
* Skips null and undefined values | ||
@@ -14,0 +15,0 @@ * Good unit test coverage |
@@ -32,3 +32,3 @@ (function (root, factory) { | ||
return function(jsonObject, parentKey, carryFormData) { | ||
function convert(jsonObject, parentKey, carryFormData) { | ||
@@ -61,5 +61,12 @@ var formData = carryFormData || new FormData(); | ||
} else if (jsonObject[key] instanceof FileList) { | ||
for (var j = 0; j < jsonObject[key].length; j++) { | ||
formData.append(propName + '[' + j + ']', jsonObject[key].item(j)); | ||
} | ||
} else if (isArray(jsonObject[key]) || isObject(jsonObject[key])) { | ||
window.jsonToFormData(jsonObject[key], propName, formData); | ||
convert(jsonObject[key], propName, formData); | ||
@@ -81,3 +88,5 @@ } else if (typeof jsonObject[key] === 'boolean') { | ||
return formData; | ||
}; | ||
} | ||
return convert; | ||
})); |
@@ -26,15 +26,2 @@ describe('jsonToFormData', function() { | ||
xit('should append File objects', function() { | ||
var testObject = { | ||
prop1: new File(['some file content'], 'my_file.txt') | ||
}; | ||
var formDataResult = window.jsonToFormData(testObject); | ||
var formDataFile = formDataResult.get('prop1'); | ||
expect(formDataFile instanceof File).to.equal(true); | ||
}); | ||
it('should convert true to 1 and false to 0', function() { | ||
@@ -41,0 +28,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59
16503
330