@capacitor/android 5.7.6 → 5.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,22 +65,29 @@ var nativeBridge = (function (exports) {
65
65
  return newFormData;
66
66
  };
67
67
  const convertBody = async (body, contentType) => {
68
- if (body instanceof ReadableStream) {
69
- const reader = body.getReader();
70
- const chunks = [];
71
- while (true) {
72
- const { done, value } = await reader.read();
73
- if (done)
74
- break;
75
- chunks.push(value);
68
+ if (body instanceof ReadableStream || body instanceof Uint8Array) {
69
+ let encodedData;
70
+ if (body instanceof ReadableStream) {
71
+ const reader = body.getReader();
72
+ const chunks = [];
73
+ while (true) {
74
+ const { done, value } = await reader.read();
75
+ if (done)
76
+ break;
77
+ chunks.push(value);
78
+ }
79
+ const concatenated = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
80
+ let position = 0;
81
+ for (const chunk of chunks) {
82
+ concatenated.set(chunk, position);
83
+ position += chunk.length;
84
+ }
85
+ encodedData = concatenated;
76
86
  }
77
- const concatenated = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
78
- let position = 0;
79
- for (const chunk of chunks) {
80
- concatenated.set(chunk, position);
81
- position += chunk.length;
87
+ else {
88
+ encodedData = body;
82
89
  }
83
- let data = new TextDecoder().decode(concatenated);
90
+ let data = new TextDecoder().decode(encodedData);
84
91
  let type;
85
92
  if (contentType === 'application/json') {
86
93
  try {
@@ -367,7 +367,7 @@ public class Bridge {
367
367
  }
368
368
  }
369
369
 
370
- if (url.getScheme().equals("data")) {
370
+ if (url.getScheme().equals("data") || url.getScheme().equals("blob")) {
371
371
  return false;
372
372
  }
373
373
 
@@ -275,7 +275,7 @@ public class CapacitorHttpUrlConnection implements ICapacitorHttpUrlConnection {
275
275
  if (type.equals("string")) {
276
276
  os.writeBytes(twoHyphens + boundary + lineEnd);
277
277
  os.writeBytes("Content-Disposition: form-data; name=\"" + key + "\"" + lineEnd + lineEnd);
278
- os.writeBytes(value);
278
+ os.write(value.getBytes(StandardCharsets.UTF_8));
279
279
  os.writeBytes(lineEnd);
280
280
  } else if (type.equals("base64File")) {
281
281
  String fileName = entry.getString("fileName");
@@ -289,6 +289,8 @@ public class CapacitorHttpUrlConnection implements ICapacitorHttpUrlConnection {
289
289
 
290
290
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
291
291
  os.write(Base64.getDecoder().decode(value));
292
+ } else {
293
+ os.write(android.util.Base64.decode(value, android.util.Base64.DEFAULT));
292
294
  }
293
295
 
294
296
  os.writeBytes(lineEnd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "5.7.6",
3
+ "version": "5.7.7",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",