Skip to content

Commit

Permalink
(#7862) - response.buffer() and blob.type have no/limited access in R…
Browse files Browse the repository at this point in the history
…eactNative

response.buffer() is not supported at all, and blob.type is readonly in
ReactNative. Change the limited node/browser detection to (hopefully)
future-proof feature detection instead.

Errors fixed in RN:

    Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not
    supported

    Cannot set property type of #<Blob> which has only a getter at

Fixes #7688 and #7727
  • Loading branch information
garfieldnate authored and daleharvey committed Aug 7, 2019
1 parent 04017dd commit 8351070
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/node_modules/pouchdb-adapter-http/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,16 @@ function HttpPouch(opts, callback) {
var path = encodeDocId(doc._id) + '/' + encodeAttachmentId(filename) +
'?rev=' + doc._rev;
return ourFetch(genDBUrl(host, path)).then(function (response) {
if (typeof process !== 'undefined' && !process.browser) {
if ('buffer' in response) {
return response.buffer();
} else {
/* istanbul ignore next */
return response.blob();
}
}).then(function (blob) {
if (opts.binary) {
// TODO: Can we remove this?
if (typeof process !== 'undefined' && !process.browser) {
var typeFieldDescriptor = Object.getOwnPropertyDescriptor(blob.__proto__, 'type');
if (!typeFieldDescriptor || typeFieldDescriptor.set) {
blob.type = att.content_type;
}
return blob;
Expand Down Expand Up @@ -875,7 +875,7 @@ function HttpPouch(opts, callback) {
if (opts.descending) {
params.descending = true;
}

/* istanbul ignore if */
if (opts.update_seq) {
params.update_seq = true;
Expand Down

0 comments on commit 8351070

Please sign in to comment.