From 080be74fa8ebb58d1f30a272c35f854506573620 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 2 Apr 2024 17:02:23 +0200 Subject: [PATCH] fix(http): Add URLSearchParams support (#7376) Co-authored-by: Phil Jones --- android/capacitor/src/main/assets/native-bridge.js | 6 ++++++ core/native-bridge.ts | 5 +++++ ios/Capacitor/Capacitor/assets/native-bridge.js | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/android/capacitor/src/main/assets/native-bridge.js b/android/capacitor/src/main/assets/native-bridge.js index d2e2a91ab5..753680cd45 100644 --- a/android/capacitor/src/main/assets/native-bridge.js +++ b/android/capacitor/src/main/assets/native-bridge.js @@ -109,6 +109,12 @@ var nativeBridge = (function (exports) { headers: { 'Content-Type': contentType || 'application/octet-stream' }, }; } + else if (body instanceof URLSearchParams) { + return { + data: body.toString(), + type: 'text', + }; + } else if (body instanceof FormData) { const formData = await convertFormData(body); const boundary = `${Date.now()}`; diff --git a/core/native-bridge.ts b/core/native-bridge.ts index 6f4d61b0c0..62f4e56de4 100644 --- a/core/native-bridge.ts +++ b/core/native-bridge.ts @@ -96,6 +96,11 @@ const convertBody = async ( type, headers: { 'Content-Type': contentType || 'application/octet-stream' }, }; + } else if (body instanceof URLSearchParams) { + return { + data: body.toString(), + type: 'text', + }; } else if (body instanceof FormData) { const formData = await convertFormData(body); const boundary = `${Date.now()}`; diff --git a/ios/Capacitor/Capacitor/assets/native-bridge.js b/ios/Capacitor/Capacitor/assets/native-bridge.js index d2e2a91ab5..753680cd45 100644 --- a/ios/Capacitor/Capacitor/assets/native-bridge.js +++ b/ios/Capacitor/Capacitor/assets/native-bridge.js @@ -109,6 +109,12 @@ var nativeBridge = (function (exports) { headers: { 'Content-Type': contentType || 'application/octet-stream' }, }; } + else if (body instanceof URLSearchParams) { + return { + data: body.toString(), + type: 'text', + }; + } else if (body instanceof FormData) { const formData = await convertFormData(body); const boundary = `${Date.now()}`;