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

GitToTheHub pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git


The following commit(s) were added to refs/heads/master by this push:
     new f71de8f  fix(ios): Don't call `beforeload` on POST and 
`beforeload=yes` (#1144)
f71de8f is described below

commit f71de8f305ea62cfd7421b0de93c81f6b559ecf3
Author: Manuel Beck <[email protected]>
AuthorDate: Wed May 6 17:27:17 2026 +0200

    fix(ios): Don't call `beforeload` on POST and `beforeload=yes` (#1144)
    
    - 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 129303f..f8cec46 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -465,8 +465,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;
@@ -475,12 +476,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;
     }
 
@@ -1161,9 +1161,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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to