Skip to content

Commit

Permalink
fix: add http method to prototype.open (#6740)
Browse files Browse the repository at this point in the history
  • Loading branch information
markemer authored Jul 17, 2023
1 parent 67c7f6e commit 1fd2d87
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions android/capacitor/src/main/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ var nativeBridge = (function (exports) {
// XHR patch open
prototype.open = function (method, url) {
this._url = url;
this._method = method;
if (!(url.startsWith('http:') || url.toString().startsWith('https:'))) {
return win.CapacitorWebXMLHttpRequest.open.call(this, method, url);
}
Expand Down
1 change: 1 addition & 0 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ const initBridge = (w: any): void => {
// XHR patch open
prototype.open = function (method: string, url: string) {
this._url = url;
this._method = method;

if (
!(url.startsWith('http:') || url.toString().startsWith('https:'))
Expand Down
1 change: 1 addition & 0 deletions ios/Capacitor/Capacitor/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ var nativeBridge = (function (exports) {
// XHR patch open
prototype.open = function (method, url) {
this._url = url;
this._method = method;
if (!(url.startsWith('http:') || url.toString().startsWith('https:'))) {
return win.CapacitorWebXMLHttpRequest.open.call(this, method, url);
}
Expand Down

2 comments on commit 1fd2d87

@JanMisker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markemer I came here to see whether this was fixed. It's quite a vital bug, anything that's not GET simply fails because the request is turned into a GET-request always. Any prognoses on when this is released? Any workaround?

@JanMisker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found my own workaround, something like myXhr._method = "POST" suffices for now, before myXhr.send().

Please sign in to comment.