@capacitor/android 6.0.0-rc.1 → 6.0.0

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.
@@ -109,6 +109,12 @@ var nativeBridge = (function (exports) {
109
109
  headers: { 'Content-Type': contentType || 'application/octet-stream' },
110
110
  };
111
111
  }
112
+ else if (body instanceof URLSearchParams) {
113
+ return {
114
+ data: body.toString(),
115
+ type: 'text',
116
+ };
117
+ }
112
118
  else if (body instanceof FormData) {
113
119
  const formData = await convertFormData(body);
114
120
  return {
@@ -141,13 +147,10 @@ var nativeBridge = (function (exports) {
141
147
  const proxyUrl = new URL(url);
142
148
  const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : '');
143
149
  const isHttps = proxyUrl.protocol === 'https:';
144
- const originalHost = encodeURIComponent(proxyUrl.host);
145
- const originalPathname = proxyUrl.pathname;
146
- proxyUrl.protocol = bridgeUrl.protocol;
147
- proxyUrl.hostname = bridgeUrl.hostname;
148
- proxyUrl.port = bridgeUrl.port;
149
- proxyUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${originalHost}${originalPathname}`;
150
- return proxyUrl.toString();
150
+ bridgeUrl.search = proxyUrl.search;
151
+ bridgeUrl.hash = proxyUrl.hash;
152
+ bridgeUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${encodeURIComponent(proxyUrl.host)}${proxyUrl.pathname}`;
153
+ return bridgeUrl.toString();
151
154
  };
152
155
  const initBridge = (w) => {
153
156
  const getPlatformId = (win) => {
@@ -378,15 +381,15 @@ var nativeBridge = (function (exports) {
378
381
  typeof c.dir === 'function');
379
382
  };
380
383
  const serializeConsoleMessage = (msg) => {
381
- if (typeof msg === 'object') {
382
- try {
384
+ try {
385
+ if (typeof msg === 'object') {
383
386
  msg = JSON.stringify(msg);
384
387
  }
385
- catch (e) {
386
- // ignore
387
- }
388
+ return String(msg);
389
+ }
390
+ catch (e) {
391
+ return '';
388
392
  }
389
- return String(msg);
390
393
  };
391
394
  const platform = getPlatformId(win);
392
395
  if (platform == 'android' || platform == 'ios') {
@@ -495,11 +498,11 @@ var nativeBridge = (function (exports) {
495
498
  if (request.url.startsWith(`${cap.getServerUrl()}/`)) {
496
499
  return win.CapacitorWebFetch(resource, options);
497
500
  }
498
- if (!(options === null || options === void 0 ? void 0 : options.method) ||
499
- options.method.toLocaleUpperCase() === 'GET' ||
500
- options.method.toLocaleUpperCase() === 'HEAD' ||
501
- options.method.toLocaleUpperCase() === 'OPTIONS' ||
502
- options.method.toLocaleUpperCase() === 'TRACE') {
501
+ const { method } = request;
502
+ if (method.toLocaleUpperCase() === 'GET' ||
503
+ method.toLocaleUpperCase() === 'HEAD' ||
504
+ method.toLocaleUpperCase() === 'OPTIONS' ||
505
+ method.toLocaleUpperCase() === 'TRACE') {
503
506
  if (typeof resource === 'string') {
504
507
  return await win.CapacitorWebFetch(createProxyUrl(resource, win), options);
505
508
  }
@@ -511,7 +514,7 @@ var nativeBridge = (function (exports) {
511
514
  const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`;
512
515
  console.time(tag);
513
516
  try {
514
- const { body, method } = request;
517
+ const { body } = request;
515
518
  const optionHeaders = Object.fromEntries(request.headers.entries());
516
519
  const { data: requestData, type, headers, } = await convertBody((options === null || options === void 0 ? void 0 : options.body) || body || undefined, optionHeaders['Content-Type'] || optionHeaders['content-type']);
517
520
  const nativeResponse = await cap.nativePromise('CapacitorHttp', 'request', {
@@ -52,23 +52,26 @@ public class CapacitorCookieManager extends CookieManager {
52
52
  }
53
53
 
54
54
  public String getSanitizedDomain(String url) throws URISyntaxException {
55
- if (url == null || url.isEmpty()) {
55
+ if (this.serverUrl != null && !this.serverUrl.isEmpty() && (url == null || url.isEmpty() || this.serverUrl.contains(url))) {
56
56
  url = this.serverUrl;
57
+ } else if (this.localUrl != null && !this.localUrl.isEmpty() && (url == null || url.isEmpty() || this.localUrl.contains(url))) {
58
+ url = this.localUrl;
59
+ } else try {
60
+ URI uri = new URI(url);
61
+ String scheme = uri.getScheme();
62
+ if (scheme == null || scheme.isEmpty()) {
63
+ url = "https://" + url;
64
+ }
65
+ } catch (URISyntaxException e) {
66
+ Logger.error(TAG, "Failed to get scheme from URL.", e);
57
67
  }
58
68
 
59
69
  try {
60
70
  new URI(url);
61
- } catch (Exception ignored) {
62
- url = this.localUrl;
63
-
64
- try {
65
- new URI(url);
66
- } catch (Exception error) {
67
- Logger.error(TAG, "Failed to get sanitized URL.", error);
68
- throw error;
69
- }
71
+ } catch (Exception error) {
72
+ Logger.error(TAG, "Failed to get sanitized URL.", error);
73
+ throw error;
70
74
  }
71
-
72
75
  return url;
73
76
  }
74
77
 
@@ -11,8 +11,8 @@ import com.getcapacitor.annotation.CapacitorPlugin;
11
11
  import com.getcapacitor.annotation.Permission;
12
12
  import com.getcapacitor.plugin.util.CapacitorHttpUrlConnection;
13
13
  import com.getcapacitor.plugin.util.HttpRequestHandler;
14
- import java.util.HashMap;
15
14
  import java.util.Map;
15
+ import java.util.concurrent.ConcurrentHashMap;
16
16
  import java.util.concurrent.ExecutorService;
17
17
  import java.util.concurrent.Executors;
18
18
 
@@ -24,7 +24,7 @@ import java.util.concurrent.Executors;
24
24
  )
25
25
  public class CapacitorHttp extends Plugin {
26
26
 
27
- private final Map<Runnable, PluginCall> activeRequests = new HashMap<>();
27
+ private final Map<Runnable, PluginCall> activeRequests = new ConcurrentHashMap<>();
28
28
  private final ExecutorService executor = Executors.newCachedThreadPool();
29
29
 
30
30
  @Override
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "6.0.0-rc.1",
3
+ "version": "6.0.0",
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)",
@@ -23,7 +23,7 @@
23
23
  "verify": "./gradlew clean lint build test -b capacitor/build.gradle"
24
24
  },
25
25
  "peerDependencies": {
26
- "@capacitor/core": "^6.0.0-rc.1"
26
+ "@capacitor/core": "^6.0.0"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"