diff --git a/android/capacitor/src/main/assets/native-bridge.js b/android/capacitor/src/main/assets/native-bridge.js index 2db2545b3..f0f70e6b3 100644 --- a/android/capacitor/src/main/assets/native-bridge.js +++ b/android/capacitor/src/main/assets/native-bridge.js @@ -145,13 +145,10 @@ var nativeBridge = (function (exports) { const proxyUrl = new URL(url); const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : ''); const isHttps = proxyUrl.protocol === 'https:'; - const originalHost = encodeURIComponent(proxyUrl.host); - const originalPathname = proxyUrl.pathname; - proxyUrl.protocol = bridgeUrl.protocol; - proxyUrl.hostname = bridgeUrl.hostname; - proxyUrl.port = bridgeUrl.port; - proxyUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${originalHost}${originalPathname}`; - return proxyUrl.toString(); + bridgeUrl.search = proxyUrl.search; + bridgeUrl.hash = proxyUrl.hash; + bridgeUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${encodeURIComponent(proxyUrl.host)}${proxyUrl.pathname}`; + return bridgeUrl.toString(); }; const initBridge = (w) => { const getPlatformId = (win) => { diff --git a/core/native-bridge.ts b/core/native-bridge.ts index 48e9e5ef8..9f3653c7a 100644 --- a/core/native-bridge.ts +++ b/core/native-bridge.ts @@ -135,15 +135,12 @@ const createProxyUrl = (url: string, win: WindowCapacitor): string => { const proxyUrl = new URL(url); const bridgeUrl = new URL(win.Capacitor?.getServerUrl() ?? ''); const isHttps = proxyUrl.protocol === 'https:'; - const originalHost = encodeURIComponent(proxyUrl.host); - const originalPathname = proxyUrl.pathname; - proxyUrl.protocol = bridgeUrl.protocol; - proxyUrl.hostname = bridgeUrl.hostname; - proxyUrl.port = bridgeUrl.port; - proxyUrl.pathname = `${ + bridgeUrl.search = proxyUrl.search; + bridgeUrl.hash = proxyUrl.hash; + bridgeUrl.pathname = `${ isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR - }/${originalHost}${originalPathname}`; - return proxyUrl.toString(); + }/${encodeURIComponent(proxyUrl.host)}${proxyUrl.pathname}`; + return bridgeUrl.toString(); }; const initBridge = (w: any): void => { diff --git a/ios/Capacitor/Capacitor/assets/native-bridge.js b/ios/Capacitor/Capacitor/assets/native-bridge.js index 2db2545b3..f0f70e6b3 100644 --- a/ios/Capacitor/Capacitor/assets/native-bridge.js +++ b/ios/Capacitor/Capacitor/assets/native-bridge.js @@ -145,13 +145,10 @@ var nativeBridge = (function (exports) { const proxyUrl = new URL(url); const bridgeUrl = new URL((_b = (_a = win.Capacitor) === null || _a === void 0 ? void 0 : _a.getServerUrl()) !== null && _b !== void 0 ? _b : ''); const isHttps = proxyUrl.protocol === 'https:'; - const originalHost = encodeURIComponent(proxyUrl.host); - const originalPathname = proxyUrl.pathname; - proxyUrl.protocol = bridgeUrl.protocol; - proxyUrl.hostname = bridgeUrl.hostname; - proxyUrl.port = bridgeUrl.port; - proxyUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${originalHost}${originalPathname}`; - return proxyUrl.toString(); + bridgeUrl.search = proxyUrl.search; + bridgeUrl.hash = proxyUrl.hash; + bridgeUrl.pathname = `${isHttps ? CAPACITOR_HTTPS_INTERCEPTOR : CAPACITOR_HTTP_INTERCEPTOR}/${encodeURIComponent(proxyUrl.host)}${proxyUrl.pathname}`; + return bridgeUrl.toString(); }; const initBridge = (w) => { const getPlatformId = (win) => {