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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8b60dca8 fix: Avoid showing error page on cancelled navigation (#1483)
8b60dca8 is described below

commit 8b60dca89bba023c063864119802c138288bb356
Author: Darryl Pogue <dar...@dpogue.ca>
AuthorDate: Thu Aug 29 03:13:07 2024 -0700

    fix: Avoid showing error page on cancelled navigation (#1483)
    
    This was previously implemented back in the UIWebView days as CB-13222
    in https://github.com/apache/cordova-ios/pull/334 and was then proposed
    in https://github.com/apache/cordova-plugin-wkwebview-engine/pull/84 for
    the WKWebView plugin, but that didn't get reviewed/merged before the
    repo was archived. The fix is still valid, so we'll port it to the
    current version of the WKWebView plugin.
    
    Closes GH-959.
    
    Co-authored-by: Gwyn Judd <gj...@stayinfront.com>
---
 .../Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git 
a/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m 
b/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m
index 78e066fd..f0c60362 100644
--- a/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m
+++ b/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m
@@ -509,17 +509,17 @@
 
 - (void)webView:(WKWebView*)theWebView 
didFailNavigation:(WKNavigation*)navigation withError:(NSError*)error
 {
-    CDVViewController* vc = (CDVViewController*)self.viewController;
-
     NSString* message = [NSString stringWithFormat:@"Failed to load webpage 
with error: %@", [error localizedDescription]];
     NSLog(@"%@", message);
 
-    NSURL* errorUrl = vc.errorURL;
-    if (errorUrl) {
-        NSCharacterSet *charSet = [NSCharacterSet 
URLFragmentAllowedCharacterSet];
-        errorUrl = [NSURL URLWithString:[NSString 
stringWithFormat:@"?error=%@", [message 
stringByAddingPercentEncodingWithAllowedCharacters:charSet]] 
relativeToURL:errorUrl];
-        NSLog(@"%@", [errorUrl absoluteString]);
-        [theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
+    if (error.code != NSURLErrorCancelled) {
+        NSURL* errorUrl = self.viewController.errorURL;
+        if (errorUrl) {
+            NSCharacterSet *charSet = [NSCharacterSet 
URLFragmentAllowedCharacterSet];
+            errorUrl = [NSURL URLWithString:[NSString 
stringWithFormat:@"?error=%@", [message 
stringByAddingPercentEncodingWithAllowedCharacters:charSet]] 
relativeToURL:errorUrl];
+            NSLog(@"%@", [errorUrl absoluteString]);
+            [theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
+        }
     }
 }
 


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

Reply via email to