formdata-polyfill
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -365,3 +365,12 @@ // ==ClosureCompiler== | ||
XMLHttpRequest.prototype.send = function(data) { | ||
_send.call(this, data instanceof FormDataPolyfill ? data['_blob']() : data) | ||
// I would check if Content-Type isn't already set | ||
// But xhr lacks getRequestHeaders functionallity | ||
// https://github.com/jimmywarting/FormData/issues/44 | ||
if (data instanceof FormDataPolyfill) { | ||
const blob = data._blob() | ||
this.setRequestHeader('Content-Type', blob.type) | ||
_send.call(this, blob) | ||
} else { | ||
_send.call(this, data) | ||
} | ||
} | ||
@@ -368,0 +377,0 @@ |
@@ -12,3 +12,3 @@ var g,k="function"==typeof Object.defineProperties?Object.defineProperty:function(b,a,d){b!=Array.prototype&&b!=Object.prototype&&(b[a]=d.value)},l="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function n(){n=function(){};l.Symbol||(l.Symbol=p)}var p=function(){var b=0;return function(a){return"jscomp_symbol_"+(a||"")+b++}}(); | ||
c=c.next().value;b.append(d,c)}return b};H.prototype._blob=function(){for(var b="----formdata-polyfill-"+Math.random(),a=[],d=w(this),c=d.next();!c.done;c=d.next()){var e=w(c.value);c=e.next().value;e=e.next().value;a.push("--"+b+"\r\n");e instanceof Blob?a.push('Content-Disposition: form-data; name="'+c+'"; filename="'+e.name+'"\r\n',"Content-Type: "+(e.type||"application/octet-stream")+"\r\n\r\n",e,"\r\n"):a.push('Content-Disposition: form-data; name="'+c+'"\r\n\r\n'+e+"\r\n")}a.push("--"+b+"--"); | ||
return new Blob(a,{type:"multipart/form-data; boundary="+b})};n();q();H.prototype[Symbol.iterator]=function(){return this.entries()};H.prototype.toString=function(){return"[object FormData]"};E&&(H.prototype[E]="FormData");[["append",x],["delete",y],["get",y],["getAll",y],["has",y],["set",x]].forEach(function(b){var a=H.prototype[b[0]];H.prototype[b[0]]=function(){return a.apply(this,b[1].apply(this,G(arguments)))}});XMLHttpRequest.prototype.send=function(b){C.call(this,b instanceof H?b._blob():b)}; | ||
if(D){var K=window.fetch;window.fetch=function(b,a){a&&a.body&&a.body instanceof H&&(a.body=a.body._blob());return K(b,a)}}window.FormData=H}; | ||
return new Blob(a,{type:"multipart/form-data; boundary="+b})};n();q();H.prototype[Symbol.iterator]=function(){return this.entries()};H.prototype.toString=function(){return"[object FormData]"};E&&(H.prototype[E]="FormData");[["append",x],["delete",y],["get",y],["getAll",y],["has",y],["set",x]].forEach(function(b){var a=H.prototype[b[0]];H.prototype[b[0]]=function(){return a.apply(this,b[1].apply(this,G(arguments)))}});XMLHttpRequest.prototype.send=function(b){b instanceof H&&(b=b.a(),this.setRequestHeader("Content-Type", | ||
b.type));C.call(this,b)};if(D){var K=window.fetch;window.fetch=function(b,a){a&&a.body&&a.body instanceof H&&(a.body=a.body._blob());return K(b,a)}}window.FormData=H}; |
{ | ||
"name": "formdata-polyfill", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "HTML5 `FormData` polyfill for Browsers.", | ||
@@ -5,0 +5,0 @@ "main": "formdata.min.js", |
# FormData | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/jimmywarting/FormData.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/jimmywarting/FormData.svg?branch=master)](https://travis-ci.org/jimmywarting/FormData) | ||
[![npm version][npm-image]][npm-url] | ||
@@ -67,3 +71,3 @@ | ||
[npm-image]: https://img.shields.io/npm/v/formdata-polyfill.svg?style=flat-square | ||
[npm-image]: https://img.shields.io/npm/v/formdata-polyfill.svg | ||
[npm-url]: https://www.npmjs.com/package/formdata-polyfill |
@@ -140,3 +140,3 @@ const nativeFormData = window.FormData | ||
// File constructor | ||
it('Shold return correct filename', () => { | ||
it('Shold return correct filename with File', () => { | ||
const fd = create_formdata(['key', new nativeFile([], 'doc.txt')]) | ||
@@ -146,2 +146,14 @@ const mockFile = fd.get('key') | ||
}) | ||
it('Shold return correct filename with Blob filename', () => { | ||
const fd = create_formdata(['key', new Blob, 'doc.txt']) | ||
const mockFile = fd.get('key') | ||
assert.equal('doc.txt', mockFile.name) | ||
}) | ||
it('Shold return correct filename with just Blob', () => { | ||
const fd = create_formdata(['key', new Blob]) | ||
const mockFile = fd.get('key') | ||
assert.equal('Blob', mockFile.name) | ||
}) | ||
}) | ||
@@ -148,0 +160,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
26499
532
73