public String resolveFileProtocol(String path)
{
/*
- * paste data
+ * is it paste data?
*/
if (path.startsWith("PASTE"))
{
}
/*
- * a URL
+ * is it a URL?
*/
if (path.indexOf("://") != -1)
{
}
/*
- * 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))
{
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
{