@capacitor/android 5.7.1 → 5.7.3
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.
|
@@ -142,11 +142,14 @@ var nativeBridge = (function (exports) {
|
|
|
142
142
|
var _a, _b;
|
|
143
143
|
if (isRelativeOrProxyUrl(url))
|
|
144
144
|
return url;
|
|
145
|
-
|
|
145
|
+
const proxyUrl = new URL(url);
|
|
146
|
+
const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : '');
|
|
146
147
|
const isHttps = proxyUrl.protocol === 'https:';
|
|
147
148
|
const originalHost = encodeURIComponent(proxyUrl.host);
|
|
148
149
|
const originalPathname = proxyUrl.pathname;
|
|
149
|
-
proxyUrl =
|
|
150
|
+
proxyUrl.protocol = bridgeUrl.protocol;
|
|
151
|
+
proxyUrl.hostname = bridgeUrl.hostname;
|
|
152
|
+
proxyUrl.port = bridgeUrl.port;
|
|
150
153
|
proxyUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${originalHost}${originalPathname}`;
|
|
151
154
|
return proxyUrl.toString();
|
|
152
155
|
};
|
|
@@ -501,9 +504,13 @@ var nativeBridge = (function (exports) {
|
|
|
501
504
|
options.method.toLocaleUpperCase() === 'HEAD' ||
|
|
502
505
|
options.method.toLocaleUpperCase() === 'OPTIONS' ||
|
|
503
506
|
options.method.toLocaleUpperCase() === 'TRACE') {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
+
if (typeof resource === 'string') {
|
|
508
|
+
return await win.CapacitorWebFetch(createProxyUrl(resource, win), options);
|
|
509
|
+
}
|
|
510
|
+
else if (resource instanceof Request) {
|
|
511
|
+
const modifiedRequest = new Request(createProxyUrl(resource.url, win), resource);
|
|
512
|
+
return await win.CapacitorWebFetch(modifiedRequest, options);
|
|
513
|
+
}
|
|
507
514
|
}
|
|
508
515
|
const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`;
|
|
509
516
|
console.time(tag);
|
|
@@ -69,12 +69,17 @@ class JSInjector {
|
|
|
69
69
|
* @return
|
|
70
70
|
*/
|
|
71
71
|
public InputStream getInjectedStream(InputStream responseStream) {
|
|
72
|
-
String js = "<script type=\"text/javascript\">" + getScriptString()
|
|
72
|
+
String js = "<script type=\"text/javascript\">" + getScriptString() + "</script>";
|
|
73
73
|
String html = this.readAssetStream(responseStream);
|
|
74
|
+
|
|
75
|
+
// Insert the js string at the position after <head> or before </head> using StringBuilder
|
|
76
|
+
StringBuilder modifiedHtml = new StringBuilder(html);
|
|
74
77
|
if (html.contains("<head>")) {
|
|
75
|
-
html
|
|
78
|
+
modifiedHtml.insert(html.indexOf("<head>") + "<head>".length(), "\n" + js + "\n");
|
|
79
|
+
html = modifiedHtml.toString();
|
|
76
80
|
} else if (html.contains("</head>")) {
|
|
77
|
-
html
|
|
81
|
+
modifiedHtml.insert(html.indexOf("</head>"), "\n" + js + "\n");
|
|
82
|
+
html = modifiedHtml.toString();
|
|
78
83
|
} else {
|
|
79
84
|
Logger.error("Unable to inject Capacitor, Plugins won't work");
|
|
80
85
|
}
|
package/package.json
CHANGED