Skip to content

Commit b39678c

Browse files
committed
simplify
1 parent 5b7cc17 commit b39678c

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

android/capacitor/src/main/assets/native-bridge.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,9 @@ var nativeBridge = (function (exports) {
473473
if ((options === null || options === void 0 ? void 0 : options.body) instanceof FormData &&
474474
(contentType === null || contentType === void 0 ? void 0 : contentType.includes('multipart/form-data')) &&
475475
!contentType.includes('boundary')) {
476-
if (options.headers instanceof Headers) {
477-
options.headers.delete('Content-Type');
478-
options.headers.delete('content-type');
479-
}
480-
else if (Array.isArray(options.headers)) {
481-
options.headers = options.headers.filter(([key]) => key !== 'Content-Type' && key !== 'content-type');
482-
}
483-
else if (options.headers) {
484-
delete options.headers['Content-Type'];
485-
delete options.headers['content-type'];
486-
}
476+
headers.delete('Content-Type');
477+
headers.delete('content-type');
478+
options.headers = headers;
487479
}
488480
const request = new Request(resource, options);
489481
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {

core/native-bridge.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,9 @@ const initBridge = (w: any): void => {
498498
contentType?.includes('multipart/form-data') &&
499499
!contentType.includes('boundary')
500500
) {
501-
if (options.headers instanceof Headers) {
502-
options.headers.delete('Content-Type');
503-
options.headers.delete('content-type');
504-
} else if (Array.isArray(options.headers)) {
505-
options.headers = options.headers.filter(([key]) => key !== 'Content-Type' && key !== 'content-type');
506-
} else if (options.headers) {
507-
delete options.headers['Content-Type'];
508-
delete options.headers['content-type'];
509-
}
501+
headers.delete('Content-Type');
502+
headers.delete('content-type');
503+
options.headers = headers;
510504
}
511505
const request = new Request(resource, options);
512506
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {

ios/Capacitor/Capacitor/assets/native-bridge.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,9 @@ var nativeBridge = (function (exports) {
473473
if ((options === null || options === void 0 ? void 0 : options.body) instanceof FormData &&
474474
(contentType === null || contentType === void 0 ? void 0 : contentType.includes('multipart/form-data')) &&
475475
!contentType.includes('boundary')) {
476-
if (options.headers instanceof Headers) {
477-
options.headers.delete('Content-Type');
478-
options.headers.delete('content-type');
479-
}
480-
else if (Array.isArray(options.headers)) {
481-
options.headers = options.headers.filter(([key]) => key !== 'Content-Type' && key !== 'content-type');
482-
}
483-
else if (options.headers) {
484-
delete options.headers['Content-Type'];
485-
delete options.headers['content-type'];
486-
}
476+
headers.delete('Content-Type');
477+
headers.delete('content-type');
478+
options.headers = headers;
487479
}
488480
const request = new Request(resource, options);
489481
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {

0 commit comments

Comments
 (0)