Comparing version 0.4.1 to 0.5.1
44
index.js
@@ -53,16 +53,2 @@ 'use strict'; | ||
/** | ||
* Create an error object to return | ||
* @param {*} error The error | ||
* @param {Response?} response The response if available | ||
* @returns {Object} The error object | ||
*/ | ||
function createErrorObject(error, response) { | ||
return { | ||
error: error, | ||
status: response && response.statusCode || 0, | ||
response: response | ||
}; | ||
} | ||
/** | ||
* Try to figure out the filename for the given file | ||
@@ -177,7 +163,9 @@ * @param {Stream} file The file stream | ||
response.pipe(concat(function (body) { | ||
error = parseJSONBody(body) || statusText(response.statusCode); | ||
callback(createErrorObject(error, response)); | ||
error = parseJSONBody(body); | ||
error = error.message || statusText(response.statusCode); | ||
callback(new Error(error), response, error); | ||
})); | ||
} else { | ||
callback(createErrorObject(body, response)); | ||
error = body.message || statusText(response.statusCode); | ||
callback(new Error(error), response, body); | ||
} | ||
@@ -189,3 +177,3 @@ } | ||
if (error) { | ||
callback(createErrorObject(error, response)); | ||
callback(error, response); | ||
} else { | ||
@@ -464,6 +452,2 @@ handleResponse(response); | ||
// switch to old style streams to make it work properly with | ||
// form-data | ||
source.resume(); | ||
source.pipe(file); | ||
@@ -596,3 +580,9 @@ source.pipe(cached); | ||
url = client.documentsURL + '/' + id + '/content' + extension; | ||
return req(url, handler); | ||
var r = req(url, handler); | ||
r.on('request', function (re) { | ||
if (re.xhr) { | ||
re.xhr.responseType = 'arraybuffer'; | ||
} | ||
}); | ||
return r; | ||
}, | ||
@@ -639,3 +629,9 @@ | ||
url = client.documentsURL + '/' + id + '/thumbnail?' + query; | ||
return req(url, handler); | ||
var r = req(url, handler); | ||
r.on('request', function (re) { | ||
if (re.xhr) { | ||
re.xhr.responseType = 'arraybuffer'; | ||
} | ||
}); | ||
return r; | ||
} | ||
@@ -642,0 +638,0 @@ }; |
{ | ||
"name": "box-view", | ||
"version": "0.4.1", | ||
"version": "0.5.1", | ||
"description": "A node client for the Box View API", | ||
@@ -36,3 +36,3 @@ "main": "index.js", | ||
"form-data": "^0.1.4", | ||
"hyperquest": "^0.3.0" | ||
"hyperquest": "https://github.com/lakenen/hyperquest/tarball/emit-request" | ||
}, | ||
@@ -39,0 +39,0 @@ "devDependencies": { |
@@ -102,3 +102,3 @@ var TOKEN = 'test api token'; | ||
var id = 'abc', | ||
err = { | ||
error = { | ||
message: 'Not found', | ||
@@ -111,7 +111,7 @@ type: 'error', | ||
.get('/1/documents/' + id) | ||
.reply(404, err); | ||
.reply(404, error); | ||
client.documents.get(id, function (err, doc) { | ||
client.documents.get(id, function (err, body) { | ||
t.ok(err, 'should be an error'); | ||
t.notOk(doc, 'should not be a doc'); | ||
t.deepEqual(body, error, 'should be error body'); | ||
t.ok(request.isDone(), 'request should be made properly'); | ||
@@ -143,3 +143,3 @@ }); | ||
var id = 'abc', | ||
err = { | ||
error = { | ||
message: 'Not found', | ||
@@ -153,7 +153,7 @@ type: 'error', | ||
.put('/1/documents/' + id, data) | ||
.reply(404, err); | ||
.reply(404, error); | ||
client.documents.update(id, data, function (err, doc) { | ||
client.documents.update(id, data, function (err, body) { | ||
t.ok(err, 'should be an error'); | ||
t.notOk(doc, 'should not be a doc'); | ||
t.deepEqual(error, body, 'should be error body'); | ||
t.ok(request.isDone(), 'request should be made properly'); | ||
@@ -160,0 +160,0 @@ }); |
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
73726
1089
1
- Removedduplexer@0.1.2(transitive)
- Removedhyperquest@0.3.0(transitive)
- Removedthrough@2.2.7(transitive)
Updatedhyperquest@https://github.com/lakenen/hyperquest/tarball/emit-request