Revision: 13867
          http://sourceforge.net/p/skim-app/code/13867
Author:   hofman
Date:     2023-12-09 17:49:40 +0000 (Sat, 09 Dec 2023)
Log Message:
-----------
redirect relative links to converted pdf bundles, don't change url when 
redirected url does not exist

Modified Paths:
--------------
    trunk/SKMainWindowController_UI.m

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2023-12-09 17:20:20 UTC (rev 13866)
+++ trunk/SKMainWindowController_UI.m   2023-12-09 17:49:40 UTC (rev 13867)
@@ -1399,10 +1399,19 @@
         NSString *path = [url path];
         NSURL *docURL = [[self document] fileURL];
         NSString *docPath = [docURL path];
+        NSURL *replaceURL = nil;
         if ([docPath hasSuffix:@"/"] == NO)
             docPath = [docPath stringByAppendingString:@"/"];
-        if ([path hasPrefix:docPath])
-            url = [[docURL URLByDeletingLastPathComponent] 
URLByAppendingPathComponent:[path substringFromIndex:[docPath length]]];
+        if ([path hasPrefix:docPath]) {
+            replaceURL = [[docURL URLByDeletingLastPathComponent] 
URLByAppendingPathComponent:[path substringFromIndex:[docPath length]]];
+            if ([replaceURL checkResourceIsReachableAndReturnError:NULL]) {
+                url = replaceURL;
+            } else if ([[url pathExtension] isCaseInsensitiveEqual:@"pdf"]) {
+                replaceURL = [replaceURL URLReplacingPathExtension:@"pdfd"];
+                if ([replaceURL checkResourceIsReachableAndReturnError:NULL])
+                    url = replaceURL;
+            }
+        }
     }
     return url;
 }

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to