Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "popsicle", | ||
"main": "popsicle.js", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/blakeembrey/popsicle", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "popsicle", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Simple HTTP requests for node and the browser", | ||
@@ -5,0 +5,0 @@ "main": "popsicle.js", |
@@ -5,2 +5,7 @@ (function (root) { | ||
var _hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var FORM_EQ = '='; | ||
var FORM_SEP = '&'; | ||
var JSON_MIME_REGEXP = /^application\/(?:[\w!#\$%&\*`\-\.\^~]*\+)?json$/i; | ||
@@ -19,2 +24,20 @@ var QUERY_MIME_REGEXP = /^application\/x-www-form-urlencoded$/i; | ||
/** | ||
* Copy objects onto another. | ||
* | ||
* @param {Object} dest | ||
* @return {Object} | ||
*/ | ||
function assign (dest /*, ...src */) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
for (var key in arguments[i]) { | ||
if (_hasOwnProperty.call(arguments[i], key)) { | ||
dest[key] = arguments[i][key]; | ||
} | ||
} | ||
} | ||
return dest; | ||
} | ||
/** | ||
* Create a stream error instance. | ||
@@ -159,5 +182,2 @@ * | ||
function stringifyQuery (obj) { | ||
var eq = '='; | ||
var sep = '&'; | ||
if (Object(obj) !== obj) { | ||
@@ -171,3 +191,3 @@ return String(obj == null ? '' : obj); | ||
var value = obj[key]; | ||
var keyStr = encode(key) + eq; | ||
var keyStr = encode(key) + FORM_EQ; | ||
@@ -183,3 +203,3 @@ if (Array.isArray(value)) { | ||
return params.join(sep); | ||
return params.join(FORM_SEP); | ||
} | ||
@@ -196,6 +216,4 @@ | ||
obj = obj || {}; | ||
qs = qs.split(sep); | ||
qs = qs.split(FORM_SEP); | ||
var sep = '&'; | ||
var eq = '='; | ||
var maxKeys = 1000; | ||
@@ -207,3 +225,3 @@ var len = qs.length > maxKeys ? maxKeys : qs.length; | ||
var value = ''; | ||
var index = key.indexOf(eq); | ||
var index = key.indexOf(FORM_EQ); | ||
@@ -218,3 +236,3 @@ if (index !== -1) { | ||
if (!obj.hasOwnProperty(key)) { | ||
if (!_hasOwnProperty.call(obj, key)) { | ||
obj[key] = value; | ||
@@ -692,3 +710,3 @@ } else if (Array.isArray(obj[key])) { | ||
this.url = options.url; | ||
this.query = options.query; | ||
this.query = assign({}, options.query); | ||
this.timeout = options.timeout; | ||
@@ -702,3 +720,3 @@ this.withCredentials = options.withCredentials === true; | ||
// Initialize the response length. | ||
this._responseTotal = null; | ||
this._responseTotal = null; | ||
this._responseLength = 0; | ||
@@ -710,7 +728,7 @@ | ||
// Parse query strings already set. | ||
var queryIndex = this.url.indexOf('?'); | ||
var queryIndex = options.url.indexOf('?'); | ||
if (queryIndex > -1) { | ||
this.query = parseQuery(this.url.substr(queryIndex + 1), this.query); | ||
this.url = this.url.substr(0, queryIndex); | ||
this.url = options.url.substr(0, queryIndex); | ||
this.query = parseQuery(options.url.substr(queryIndex + 1), this.query); | ||
} | ||
@@ -731,7 +749,6 @@ } | ||
Request.prototype.fullUrl = function () { | ||
var url = this.url; | ||
var url = this.url; | ||
var query = stringifyQuery(this.query); | ||
if (this.query) { | ||
var query = stringifyQuery(this.query); | ||
if (query) { | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + query; | ||
@@ -738,0 +755,0 @@ } |
Sorry, the diff of this file is not supported yet
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
59253
1575