From 9367ecc56a0c78249dccdf95dca5006422144289 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 2 Apr 2024 16:37:05 +0200 Subject: [PATCH] fix(http): Add URLSearchParams support (#7374) 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 fa9acbff0..4d9f1d891 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); return { diff --git a/core/native-bridge.ts b/core/native-bridge.ts index c7f106e26..9feef5ee1 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); return { diff --git a/ios/Capacitor/Capacitor/assets/native-bridge.js b/ios/Capacitor/Capacitor/assets/native-bridge.js index fa9acbff0..4d9f1d891 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); return {