@capacitor/ios 5.7.7 → 5.7.8
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.
|
@@ -91,7 +91,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol {
|
|
|
91
91
|
public static let capacitorSite = "https://capacitorjs.com/"
|
|
92
92
|
public static let fileStartIdentifier = "/_capacitor_file_"
|
|
93
93
|
public static let httpInterceptorStartIdentifier = "/_capacitor_http_interceptor_"
|
|
94
|
+
@available(*, deprecated, message: "`httpsInterceptorStartIdentifier` is no longer required. All proxied requests are handled via `httpInterceptorStartIdentifier` instead")
|
|
94
95
|
public static let httpsInterceptorStartIdentifier = "/_capacitor_https_interceptor_"
|
|
96
|
+
public static let httpInterceptorUrlParam = "u"
|
|
95
97
|
public static let defaultScheme = "capacitor"
|
|
96
98
|
|
|
97
99
|
var webViewAssetHandler: WebViewAssetHandler
|
|
@@ -35,11 +35,6 @@ internal class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
|
|
|
35
35
|
return
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if url.path.starts(with: CapacitorBridge.httpsInterceptorStartIdentifier) {
|
|
39
|
-
handleCapacitorHttpRequest(urlSchemeTask, localUrl, true)
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
if stringToLoad.starts(with: CapacitorBridge.fileStartIdentifier) {
|
|
44
39
|
startPath = stringToLoad.replacingOccurrences(of: CapacitorBridge.fileStartIdentifier, with: "")
|
|
45
40
|
} else {
|
|
@@ -138,21 +133,13 @@ internal class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
|
|
|
138
133
|
func handleCapacitorHttpRequest(_ urlSchemeTask: WKURLSchemeTask, _ localUrl: URL, _ isHttpsRequest: Bool) {
|
|
139
134
|
var urlRequest = urlSchemeTask.request
|
|
140
135
|
guard let url = urlRequest.url else { return }
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
targetUrl = targetUrl.replacingCharacters(in: range, with: isHttpsRequest ? "https" : "http")
|
|
136
|
+
|
|
137
|
+
let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
|
|
138
|
+
if let targetUrl = urlComponents?.queryItems?.first(where: { $0.name == CapacitorBridge.httpInterceptorUrlParam })?.value,
|
|
139
|
+
!targetUrl.isEmpty {
|
|
140
|
+
urlRequest.url = URL(string: targetUrl)
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
// Only replace first occurrence of the hostname
|
|
150
|
-
if let range = targetUrl.range(of: (localUrl.host ?? InstanceDescriptorDefaults.hostname) + "/") {
|
|
151
|
-
targetUrl = targetUrl.replacingCharacters(in: range, with: "")
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
urlRequest.url = URL(string: targetUrl.removingPercentEncoding ?? targetUrl)
|
|
155
|
-
|
|
156
143
|
let urlSession = URLSession.shared
|
|
157
144
|
let task = urlSession.dataTask(with: urlRequest) { (data, response, error) in
|
|
158
145
|
DispatchQueue.main.async {
|
|
@@ -144,23 +144,19 @@ var nativeBridge = (function (exports) {
|
|
|
144
144
|
return { data: body, type: 'json' };
|
|
145
145
|
};
|
|
146
146
|
const CAPACITOR_HTTP_INTERCEPTOR = '/_capacitor_http_interceptor_';
|
|
147
|
-
const
|
|
147
|
+
const CAPACITOR_HTTP_INTERCEPTOR_URL_PARAM = 'u';
|
|
148
148
|
// TODO: export as Cap function
|
|
149
149
|
const isRelativeOrProxyUrl = (url) => !url ||
|
|
150
150
|
!(url.startsWith('http:') || url.startsWith('https:')) ||
|
|
151
|
-
url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1
|
|
152
|
-
url.indexOf(CAPACITOR_HTTPS_INTERCEPTOR) > -1;
|
|
151
|
+
url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1;
|
|
153
152
|
// TODO: export as Cap function
|
|
154
153
|
const createProxyUrl = (url, win) => {
|
|
155
154
|
var _a, _b;
|
|
156
155
|
if (isRelativeOrProxyUrl(url))
|
|
157
156
|
return url;
|
|
158
|
-
const proxyUrl = new URL(url);
|
|
159
157
|
const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : '');
|
|
160
|
-
|
|
161
|
-
bridgeUrl.
|
|
162
|
-
bridgeUrl.hash = proxyUrl.hash;
|
|
163
|
-
bridgeUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${encodeURIComponent(proxyUrl.host)}${proxyUrl.pathname}`;
|
|
158
|
+
bridgeUrl.pathname = CAPACITOR_HTTP_INTERCEPTOR;
|
|
159
|
+
bridgeUrl.searchParams.append(CAPACITOR_HTTP_INTERCEPTOR_URL_PARAM, url);
|
|
164
160
|
return bridgeUrl.toString();
|
|
165
161
|
};
|
|
166
162
|
const initBridge = (w) => {
|
package/package.json
CHANGED