Revision: 29600
          http://sourceforge.net/p/bibdesk/svn/29600
Author:   hofman
Date:     2025-09-17 16:56:05 +0000 (Wed, 17 Sep 2025)
Log Message:
-----------
don't get URL from webview for failing provisional load, the URL will be from 
the previous page

Modified Paths:
--------------
    trunk/bibdesk/BDSKTextImportController.m

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2025-09-17 16:48:58 UTC (rev 
29599)
+++ trunk/bibdesk/BDSKTextImportController.m    2025-09-17 16:56:05 UTC (rev 
29600)
@@ -940,6 +940,19 @@
 
 #pragma mark WKNavigationDelegate protocol
 
+- (void)webView:(WKWebView *)aWebView 
didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError 
*)error {
+    if ([[error domain] isEqualToString:NSURLErrorDomain] == NO || [error 
code] != NSURLErrorCancelled) {
+        NSURL *url = [[error userInfo] 
objectForKey:NSURLErrorFailingURLErrorKey];
+        NSString *errorHTML = [NSString 
stringWithFormat:@"<html><head><title>%@</title></head><body><h1>%@</h1></body></html>",
 NSLocalizedString(@"Error", @"Placeholder web group label"), [error 
localizedDescription]];
+        if (url == nil)
+            [webView loadHTMLString:errorHTML baseURL:nil];
+        else if (@available(macOS 12.0, *))
+            [webView loadSimulatedRequest:[NSURLRequest requestWithURL:url] 
responseHTMLString:errorHTML];
+        else
+            [webView loadHTMLString:errorHTML baseURL:url];
+    }
+}
+
 - (void)webView:(WKWebView *)aWebView didFailNavigation:(WKNavigation 
*)navigation withError:(NSError *)error {
     if ([[error domain] isEqualToString:NSURLErrorDomain] == NO || [error 
code] != NSURLErrorCancelled) {
         NSURL *url = [[error userInfo] 
objectForKey:NSURLErrorFailingURLErrorKey] ?: [webView URL];
@@ -953,10 +966,6 @@
     }
 }
 
-- (void)webView:(WKWebView *)aWebView 
didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError 
*)error {
-    [self webView:aWebView didFailNavigation:navigation withError:error];
-}
-
 static inline NSString *contentDispositionHeader(NSURLResponse *response) {
     if ([response isKindOfClass:[NSHTTPURLResponse class]] == NO)
         return nil;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to