Skip to content

Commit

Permalink
fix(http): copy native response url to fetch response
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsChaceD authored Apr 6, 2023
1 parent aa52296 commit 42d2eb3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions android/capacitor/src/main/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,14 @@ var nativeBridge = (function (exports) {
headers: nativeResponse.headers,
status: nativeResponse.status,
});
/*
* copy url to response, `cordova-plugin-ionic` uses this url from the response
* we need `Object.defineProperty` because url is an inherited getter on the Response
* see: https://stackoverflow.com/a/57382543
* */
Object.defineProperty(response, 'url', {
value: nativeResponse.url,
});
console.timeEnd(tag);
return response;
}
Expand Down
9 changes: 9 additions & 0 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ const initBridge = (w: any): void => {
status: nativeResponse.status,
});

/*
* copy url to response, `cordova-plugin-ionic` uses this url from the response
* we need `Object.defineProperty` because url is an inherited getter on the Response
* see: https://stackoverflow.com/a/57382543
* */
Object.defineProperty(response, 'url', {
value: nativeResponse.url,
});

console.timeEnd(tag);
return response;
} catch (error) {
Expand Down
8 changes: 8 additions & 0 deletions ios/Capacitor/Capacitor/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,14 @@ var nativeBridge = (function (exports) {
headers: nativeResponse.headers,
status: nativeResponse.status,
});
/*
* copy url to response, `cordova-plugin-ionic` uses this url from the response
* we need `Object.defineProperty` because url is an inherited getter on the Response
* see: https://stackoverflow.com/a/57382543
* */
Object.defineProperty(response, 'url', {
value: nativeResponse.url,
});
console.timeEnd(tag);
return response;
}
Expand Down

0 comments on commit 42d2eb3

Please sign in to comment.