You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/05/05 12:21:34 UTC

(cordova-plugin-inappbrowser) branch pr-fix-ios-dont-call-beforeload-on-post-and-beforeload-yes created (now 8913a02)

This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a change to branch pr-fix-ios-dont-call-beforeload-on-post-and-beforeload-yes
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git


      at 8913a02  fix(ios): Don't call `beforeload` on POST and `beforeload=yes`

This branch includes the following new commits:

     new 8913a02  fix(ios): Don't call `beforeload` on POST and `beforeload=yes`

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


(cordova-plugin-inappbrowser) 01/01: fix(ios): Don't call `beforeload` on POST and `beforeload=yes`

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch pr-fix-ios-dont-call-beforeload-on-post-and-beforeload-yes
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git

commit 8913a02cf381cb9467a1bbaf7e8d93d6c27a2288
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Tue May 5 14:21:16 2026 +0200

    fix(ios): Don't call `beforeload` on POST and `beforeload=yes`
    
    - If the option `beforeload=yes` was set and a POST-Request was made, `beforeload` was fired which was wrong, because POST-Request are not supported currently for beforeload
    - Improve dectection for `isTopLevelNavigation`: Using `targetFrame` makes top-level detection based on actual frame intent, not URL coincidence, so the interception logic is more correct and robust.
    - Generated-By: GPT-5.3-Codex
---
 src/ios/CDVWKInAppBrowser.m | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index 92a35b4..7ec8cfd 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -453,8 +453,9 @@
 - (void)webView:(WKWebView *)theWebView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
 {
     NSURL *url = navigationAction.request.URL;
-    NSURL *mainDocumentURL = navigationAction.request.mainDocumentURL;
-    BOOL isTopLevelNavigation = [url isEqual:mainDocumentURL];
+    BOOL isTopLevelNavigation =
+        (navigationAction.targetFrame == nil) ||
+        navigationAction.targetFrame.isMainFrame;
     BOOL shouldStart = YES;
     BOOL useBeforeLoad = NO;
     NSString *httpMethod = navigationAction.request.HTTPMethod;
@@ -463,12 +464,11 @@
     if ([_beforeload isEqualToString:@"post"]) {
         // TODO: Handle POST requests by preserving POST data then remove this condition.
         errorMessage = @"beforeload doesn't yet support POST requests";
-    } else if (isTopLevelNavigation && (
-        [_beforeload isEqualToString:@"yes"]
-        || ([_beforeload isEqualToString:@"get"] && [httpMethod isEqualToString:@"GET"])
-        // TODO: Comment in when POST requests are handled.
-        // || ([_beforeload isEqualToString:@"post"] && [httpMethod isEqualToString:@"POST"])
-    )) {
+
+        // beforeload only on GET and when the appropriate option is set
+    } else if (isTopLevelNavigation
+               && [httpMethod isEqualToString:@"GET"]
+               && ([_beforeload isEqualToString:@"yes"] || [_beforeload isEqualToString:@"get"])) {
         useBeforeLoad = YES;
     }
 
@@ -1145,9 +1145,9 @@ decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
 decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
 {
     NSURL *url = navigationAction.request.URL;
-    NSURL *mainDocumentURL = navigationAction.request.mainDocumentURL;
-
-    BOOL isTopLevelNavigation = [url isEqual:mainDocumentURL];
+    BOOL isTopLevelNavigation =
+        (navigationAction.targetFrame == nil) ||
+        navigationAction.targetFrame.isMainFrame;
 
     if (isTopLevelNavigation) {
         self.currentURL = url;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org