Comparing version 0.3.4 to 0.3.5
{ | ||
"name": "popsicle", | ||
"main": "popsicle.js", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"homepage": "https://github.com/blakeembrey/popsicle", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "popsicle", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Simple HTTP requests for node and the browser", | ||
@@ -5,0 +5,0 @@ "main": "popsicle.js", |
@@ -268,3 +268,3 @@ (function () { | ||
if (qs == null || qs === '') { | ||
return {}; | ||
return null; | ||
} | ||
@@ -395,10 +395,2 @@ | ||
var body = response.body; | ||
// Set the body to `null` for empty responses. | ||
if (body === '') { | ||
response.body = null; | ||
return response; | ||
} | ||
var type = response.type(); | ||
@@ -408,3 +400,3 @@ | ||
if (JSON_MIME_REGEXP.test(type)) { | ||
response.body = JSON.parse(body); | ||
response.body = body === '' ? null : JSON.parse(body); | ||
} else if (QUERY_MIME_REGEXP.test(type)) { | ||
@@ -411,0 +403,0 @@ response.body = parseQuery(body); |
@@ -481,2 +481,29 @@ var isNode = typeof window === 'undefined'; | ||
}); | ||
it('should keep non-parsable responses as empty strings', function () { | ||
return popsicle({ | ||
url: REMOTE_URL + '/echo', | ||
method: 'post', | ||
headers: { | ||
'Content-Type': 'text/html' | ||
} | ||
}) | ||
.then(function (res) { | ||
expect(res.body).to.equal(''); | ||
}); | ||
}); | ||
it('should set responses to null when empty', function () { | ||
return popsicle({ | ||
url: REMOTE_URL + '/echo', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}) | ||
.then(function (res) { | ||
expect(res.body).to.equal(null); | ||
expect(res.type()).to.equal('application/json'); | ||
}); | ||
}); | ||
}); | ||
@@ -483,0 +510,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
71237
1924