Skip to content

Commit

Permalink
fix(http): Add URLSearchParams support (#7376)
Browse files Browse the repository at this point in the history
Co-authored-by: Phil Jones <pjones@vqcomms.com>
  • Loading branch information
jcesarmobile and philjones88 authored Apr 2, 2024
1 parent beceb65 commit 080be74
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions android/capacitor/src/main/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand Down
5 changes: 5 additions & 0 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand Down
6 changes: 6 additions & 0 deletions ios/Capacitor/Capacitor/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand Down

0 comments on commit 080be74

Please sign in to comment.