From 95e1400e3e807ec4eb7fb23e6d2ae2519416baa3 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 16 Sep 2015 12:57:22 +0100 Subject: [PATCH] JAL-1859 code tidy, remove 'absolute URL' option --- src/jalview/bin/JalviewLite.java | 40 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 1be926e..30b8d54 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -1798,7 +1798,7 @@ public class JalviewLite extends Applet implements public String resolveFileProtocol(String path) { /* - * paste data + * is it paste data? */ if (path.startsWith("PASTE")) { @@ -1807,7 +1807,7 @@ public class JalviewLite extends Applet implements } /* - * a URL + * is it a URL? */ if (path.indexOf("://") != -1) { @@ -1816,40 +1816,41 @@ public class JalviewLite extends Applet implements } /* - * relative to document root + * try relative to document root */ URL documentBase = getDocumentBase(); - String url = resolveUrlForLocalOrAbsolute(path, documentBase); - if (urlExists(url)) + String withDocBase = resolveUrlForLocalOrAbsolute(path, documentBase); + if (urlExists(withDocBase)) { if (debug) { System.err.println("Prepended document base '" + documentBase - + "' to make: '" + url + "'"); + + "' to make: '" + withDocBase + "'"); } protocol = AppletFormatAdapter.URL; - return url; + return withDocBase; } /* - * relative to codebase + * try relative to codebase (if different to document base) */ URL codeBase = getCodeBase(); - url = applet.resolveUrlForLocalOrAbsolute(path, codeBase); - if (urlExists(url)) + String withCodeBase = applet.resolveUrlForLocalOrAbsolute(path, + codeBase); + if (!withCodeBase.equals(withDocBase) && urlExists(withCodeBase)) { protocol = AppletFormatAdapter.URL; if (debug) { System.err.println("Prepended codebase '" + codeBase - + "' to make: '" + url + "'"); + + "' to make: '" + withCodeBase + "'"); } - return url; + return withCodeBase; } /* - * locatable by classloader; test for this last as files in the document - * root may also be found by the classloader + * try locating by classloader; try this last so files in the directory + * are resolved using document base */ if (inArchive(path)) { @@ -2962,12 +2963,13 @@ public class JalviewLite extends Applet implements if (targetPath.startsWith("/")) { /* - * construct absolute URL to a file on the server + * construct absolute URL to a file on the server - this is not allowed? */ - String localfile = localref.getFile(); - resolvedPath = urlPath.substring(0, - urlPath.length() - localfile.length()) - + targetPath; + // String localfile = localref.getFile(); + // resolvedPath = urlPath.substring(0, + // urlPath.length() - localfile.length()) + // + targetPath; + resolvedPath = directoryPath + targetPath.substring(1); } else { -- 1.7.10.2