Skip to content

Commit

Permalink
Don't allow unsupported mixing of data types (#1113)
Browse files Browse the repository at this point in the history
Closes #209
  • Loading branch information
kornelski authored and focusaurus committed Nov 19, 2016
1 parent 0eb364f commit 2aea92a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ Request.prototype.query = function(val){
*/

Request.prototype.attach = function(field, file, options){
if (this._data) {
throw Error("superagent can't mix .send() and .attach()");
}

this._getFormData().append(field, file, options || file.name);
return this;
};
Expand Down
4 changes: 4 additions & 0 deletions lib/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ RequestBase(Request.prototype);
*/

Request.prototype.attach = function(field, file, options){
if (this._data) {
throw Error("superagent can't mix .send() and .attach()");
}

var o = options || {};
if ('string' == typeof options) {
o = { filename: options };
Expand Down

0 comments on commit 2aea92a

Please sign in to comment.