Skip to content

Commit

Permalink
fix(android): make local urls use unpatched fetch (#6954)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Oct 4, 2023
1 parent 3934cf6 commit 56fb853
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
3 changes: 1 addition & 2 deletions android/capacitor/src/main/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ var nativeBridge = (function (exports) {
// fetch patch
window.fetch = async (resource, options) => {
const request = new Request(resource, options);
if (!(request.url.startsWith('http:') ||
request.url.startsWith('https:'))) {
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {
return win.CapacitorWebFetch(resource, options);
}
const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`;
Expand Down
8 changes: 1 addition & 7 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,7 @@ const initBridge = (w: any): void => {
options?: RequestInit,
) => {
const request = new Request(resource, options);

if (
!(
request.url.startsWith('http:') ||
request.url.startsWith('https:')
)
) {
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {
return win.CapacitorWebFetch(resource, options);
}

Expand Down
3 changes: 1 addition & 2 deletions ios/Capacitor/Capacitor/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ var nativeBridge = (function (exports) {
// fetch patch
window.fetch = async (resource, options) => {
const request = new Request(resource, options);
if (!(request.url.startsWith('http:') ||
request.url.startsWith('https:'))) {
if (request.url.startsWith(`${cap.getServerUrl()}/`)) {
return win.CapacitorWebFetch(resource, options);
}
const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`;
Expand Down

0 comments on commit 56fb853

Please sign in to comment.