Comparing version 2.6.2 to 2.6.3
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://homer0.github.io/wootils/", | ||
"version": "2.6.2", | ||
"version": "2.6.3", | ||
"repository": "homer0/wootils", | ||
@@ -8,0 +8,0 @@ "author": "Leonardo Apiwan (@homer0) <me@homer0.com>", |
@@ -332,9 +332,20 @@ const statuses = require('statuses'); | ||
responseStatus = response.status; | ||
/** | ||
* If the response should be handled as JSON and it has a `json()` method, return the | ||
* promise of the decoded content, otherwise just return the same object. | ||
*/ | ||
return handleAsJSON && response.json ? | ||
response.json() : | ||
response; | ||
let nextStep; | ||
// If the response should be handled as JSON and it has a `json()` method... | ||
if (handleAsJSON && typeof response.json === 'function') { | ||
/** | ||
* Make sure there's a response to be parsed, otherwise just set to return an empty | ||
* object. | ||
*/ | ||
if (typeof response.size === 'undefined' || response.size > 0) { | ||
nextStep = response.json(); | ||
} else { | ||
nextStep = {}; | ||
} | ||
} else { | ||
// If the response shouldn't be handled as JSON, set to return the raw object. | ||
nextStep = response; | ||
} | ||
return nextStep; | ||
}) | ||
@@ -341,0 +352,0 @@ .then((response) => ( |
@@ -345,2 +345,26 @@ jest.unmock('/shared/objectUtils'); | ||
it('should make a successfully GET request without decoding an empty response', () => { | ||
// Given | ||
const requestURL = 'http://example.com'; | ||
const requestResponse = { | ||
status: 200, | ||
size: 0, | ||
json: jest.fn(), | ||
}; | ||
const fetchClient = jest.fn(() => Promise.resolve(requestResponse)); | ||
let sut = null; | ||
// When | ||
sut = new APIClient('', '', fetchClient); | ||
return sut.fetch({ url: requestURL }) | ||
.then((response) => { | ||
// Then | ||
expect(response).toEqual({}); | ||
expect(requestResponse.json).toHaveBeenCalledTimes(0); | ||
expect(fetchClient).toHaveBeenCalledTimes(1); | ||
expect(fetchClient).toHaveBeenCalledWith(requestURL, { | ||
method: 'GET', | ||
}); | ||
}); | ||
}); | ||
it('should make a successfully POST request', () => { | ||
@@ -347,0 +371,0 @@ // Given |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
613102
74
8461
19
1