superagent
Advanced tools
Comparing version 3.5.2 to 3.5.3-beta.1
@@ -579,3 +579,3 @@ | ||
request.post(url) | ||
.attach(file) | ||
.attach('field_name', file) | ||
.on('progress', event => { | ||
@@ -582,0 +582,0 @@ /* the event is: |
@@ -18,3 +18,2 @@ /** | ||
var isObject = require('./is-object'); | ||
var isFunction = require('./is-function'); | ||
var ResponseBase = require('./response-base'); | ||
@@ -648,28 +647,2 @@ var shouldRetry = require('./should-retry'); | ||
/** | ||
* Compose querystring to append to req.url | ||
* | ||
* @api private | ||
*/ | ||
Request.prototype._appendQueryString = function(){ | ||
var query = this._query.join('&'); | ||
if (query) { | ||
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query; | ||
} | ||
if (this._sort) { | ||
var index = this.url.indexOf('?'); | ||
if (index >= 0) { | ||
var queryArr = this.url.substring(index + 1).split('&'); | ||
if (isFunction(this._sort)) { | ||
queryArr.sort(this._sort); | ||
} else { | ||
queryArr.sort(); | ||
} | ||
this.url = this.url.substring(0, index) + '?' + queryArr.join('&'); | ||
} | ||
} | ||
}; | ||
/** | ||
* Check if `obj` is a host object, | ||
@@ -706,3 +679,3 @@ * we don't want to serialize these :) | ||
// querystring | ||
this._appendQueryString(); | ||
this._finalizeQueryString(); | ||
@@ -709,0 +682,0 @@ return this._end(); |
@@ -27,3 +27,2 @@ | ||
var RequestBase = require('../request-base'); | ||
var isFunction = require('../is-function'); | ||
var shouldRetry = require('../should-retry'); | ||
@@ -148,3 +147,4 @@ | ||
this.qs = {}; | ||
this.qsRaw = []; | ||
this._query = []; | ||
this.qsRaw = this._query; // Unused, for backwards compatibility only | ||
this._redirectList = []; | ||
@@ -311,7 +311,6 @@ this._streamRequest = false; | ||
if ('string' == typeof val) { | ||
this.qsRaw.push(val); | ||
return this; | ||
this._query.push(val); | ||
} else { | ||
extend(this.qs, val); | ||
} | ||
extend(this.qs, val); | ||
return this; | ||
@@ -458,3 +457,3 @@ }; | ||
this.qs = {}; | ||
this.qsRaw = []; | ||
this._query.length = 0; | ||
this.set(headers); | ||
@@ -492,8 +491,8 @@ this.emit('redirect', res); | ||
case 'bearer': | ||
return this.set('Authorization', 'Bearer ' + user); | ||
return this.set('Authorization', 'Bearer ' + user); | ||
default: // 'basic' | ||
if (!~user.indexOf(':')) user = user + ':'; | ||
var str = new Buffer(user + pass).toString('base64'); | ||
return this.set('Authorization', 'Basic ' + str); | ||
return this.set('Authorization', 'Basic ' + str); | ||
} | ||
@@ -566,2 +565,14 @@ }; | ||
var options = {}; | ||
try { | ||
var query = qs.stringify(this.qs, { indices: false, strictNullHandling: true }); | ||
if (query) { | ||
this.qs = {}; | ||
this._query.push(query); | ||
} | ||
this._finalizeQueryString(); | ||
} catch (e) { | ||
return this.emit('error', e); | ||
} | ||
var url = this.url; | ||
@@ -582,3 +593,3 @@ var retries = this._retries; | ||
options.socketPath = unixParts[1].replace(/%2F/g, '/'); | ||
url.pathname = unixParts[2]; | ||
url.path = unixParts[2]; | ||
} | ||
@@ -589,3 +600,3 @@ | ||
options.port = url.port; | ||
options.path = url.pathname; | ||
options.path = url.path; | ||
options.host = url.hostname; | ||
@@ -632,6 +643,2 @@ options.ca = this._ca; | ||
// query | ||
if (url.search) | ||
this.query(url.search.substr(1)); | ||
// add cookies | ||
@@ -645,8 +652,2 @@ if (this.cookies) req.setHeader('Cookie', this.cookies); | ||
try { | ||
this._appendQueryString(req); | ||
} catch (e) { | ||
return this.emit('error', e); | ||
} | ||
return req; | ||
@@ -702,28 +703,2 @@ }; | ||
/** | ||
* Compose querystring to append to req.path | ||
* | ||
* @return {String} querystring | ||
* @api private | ||
*/ | ||
Request.prototype._appendQueryString = function(req){ | ||
var query = qs.stringify(this.qs, { indices: false, strictNullHandling: true }); | ||
query += ((query.length && this.qsRaw.length) ? '&' : '') + this.qsRaw.join('&'); | ||
req.path += query.length ? (~req.path.indexOf('?') ? '&' : '?') + query : ''; | ||
if (this._sort) { | ||
var index = req.path.indexOf('?'); | ||
if (index >= 0) { | ||
var queryArr = req.path.substring(index + 1).split('&'); | ||
if (isFunction(this._sort)) { | ||
queryArr.sort(this._sort); | ||
} else { | ||
queryArr.sort(); | ||
} | ||
req.path = req.path.substring(0, index) + '?' + queryArr.join('&'); | ||
} | ||
} | ||
}; | ||
/** | ||
* Check if `obj` is a host object, | ||
@@ -730,0 +705,0 @@ * |
@@ -558,2 +558,31 @@ /** | ||
/** | ||
* Compose querystring to append to req.url | ||
* | ||
* @api private | ||
*/ | ||
RequestBase.prototype._finalizeQueryString = function(){ | ||
var query = this._query.join('&'); | ||
if (query) { | ||
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query; | ||
} | ||
this._query.length = 0; // Makes the call idempotent | ||
if (this._sort) { | ||
var index = this.url.indexOf('?'); | ||
if (index >= 0) { | ||
var queryArr = this.url.substring(index + 1).split('&'); | ||
if ('function' === typeof this._sort) { | ||
queryArr.sort(this._sort); | ||
} else { | ||
queryArr.sort(); | ||
} | ||
this.url = this.url.substring(0, index) + '?' + queryArr.join('&'); | ||
} | ||
} | ||
}; | ||
// For backwards compat only | ||
RequestBase.prototype._appendQueryString = function() {console.trace("Unsupported");} | ||
/** | ||
* Invoke callback with timeout error. | ||
@@ -560,0 +589,0 @@ * |
{ | ||
"name": "superagent", | ||
"version": "3.5.2", | ||
"version": "3.5.3-beta.1", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -50,3 +50,3 @@ "scripts": { | ||
"should": "^11.1.1", | ||
"should-http": "^0.0.4", | ||
"should-http": "^0.1.1", | ||
"zuul": "^3.11.1" | ||
@@ -53,0 +53,0 @@ }, |
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
/** | ||
* Check if `fn` is a function. | ||
* | ||
* @param {Function} fn | ||
* @return {Boolean} | ||
* @api private | ||
*/ | ||
var isObject = require('./is-object'); | ||
function isFunction(fn) { | ||
var tag = isObject(fn) ? Object.prototype.toString.call(fn) : ''; | ||
return tag === '[object Function]'; | ||
} | ||
module.exports = isFunction; | ||
},{"./is-object":2}],2:[function(require,module,exports){ | ||
/** | ||
* Check if `obj` is an object. | ||
@@ -33,3 +16,3 @@ * | ||
},{}],3:[function(require,module,exports){ | ||
},{}],2:[function(require,module,exports){ | ||
/** | ||
@@ -592,2 +575,31 @@ * Module of mixed-in functions shared between node and client code | ||
/** | ||
* Compose querystring to append to req.url | ||
* | ||
* @api private | ||
*/ | ||
RequestBase.prototype._finalizeQueryString = function(){ | ||
var query = this._query.join('&'); | ||
if (query) { | ||
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query; | ||
} | ||
this._query.length = 0; // Makes the call idempotent | ||
if (this._sort) { | ||
var index = this.url.indexOf('?'); | ||
if (index >= 0) { | ||
var queryArr = this.url.substring(index + 1).split('&'); | ||
if ('function' === typeof this._sort) { | ||
queryArr.sort(this._sort); | ||
} else { | ||
queryArr.sort(); | ||
} | ||
this.url = this.url.substring(0, index) + '?' + queryArr.join('&'); | ||
} | ||
} | ||
}; | ||
// For backwards compat only | ||
RequestBase.prototype._appendQueryString = function() {console.trace("Unsupported");} | ||
/** | ||
* Invoke callback with timeout error. | ||
@@ -628,3 +640,3 @@ * | ||
},{"./is-object":2}],4:[function(require,module,exports){ | ||
},{"./is-object":1}],3:[function(require,module,exports){ | ||
@@ -764,3 +776,3 @@ /** | ||
},{"./utils":6}],5:[function(require,module,exports){ | ||
},{"./utils":5}],4:[function(require,module,exports){ | ||
var ERROR_CODES = [ | ||
@@ -790,3 +802,3 @@ 'ECONNRESET', | ||
},{}],6:[function(require,module,exports){ | ||
},{}],5:[function(require,module,exports){ | ||
@@ -860,3 +872,3 @@ /** | ||
}; | ||
},{}],7:[function(require,module,exports){ | ||
},{}],6:[function(require,module,exports){ | ||
@@ -1026,3 +1038,3 @@ /** | ||
},{}],8:[function(require,module,exports){ | ||
},{}],7:[function(require,module,exports){ | ||
/** | ||
@@ -1045,3 +1057,2 @@ * Root reference for iframes. | ||
var isObject = require('./is-object'); | ||
var isFunction = require('./is-function'); | ||
var ResponseBase = require('./response-base'); | ||
@@ -1675,28 +1686,2 @@ var shouldRetry = require('./should-retry'); | ||
/** | ||
* Compose querystring to append to req.url | ||
* | ||
* @api private | ||
*/ | ||
Request.prototype._appendQueryString = function(){ | ||
var query = this._query.join('&'); | ||
if (query) { | ||
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query; | ||
} | ||
if (this._sort) { | ||
var index = this.url.indexOf('?'); | ||
if (index >= 0) { | ||
var queryArr = this.url.substring(index + 1).split('&'); | ||
if (isFunction(this._sort)) { | ||
queryArr.sort(this._sort); | ||
} else { | ||
queryArr.sort(); | ||
} | ||
this.url = this.url.substring(0, index) + '?' + queryArr.join('&'); | ||
} | ||
} | ||
}; | ||
/** | ||
* Check if `obj` is a host object, | ||
@@ -1733,3 +1718,3 @@ * we don't want to serialize these :) | ||
// querystring | ||
this._appendQueryString(); | ||
this._finalizeQueryString(); | ||
@@ -1965,3 +1950,3 @@ return this._end(); | ||
},{"./is-function":1,"./is-object":2,"./request-base":3,"./response-base":4,"./should-retry":5,"component-emitter":7}]},{},[8])(8) | ||
},{"./is-object":1,"./request-base":2,"./response-base":3,"./should-retry":4,"component-emitter":6}]},{},[7])(7) | ||
}); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
367590
33
4457
2