Author: jpages Date: 2012-05-24 10:44:53 +0200 (Thu, 24 May 2012) New Revision: 671 Url: http://nuiton.org/repositories/revision/jrst/671 Log: Am?\195?\169lioration de la r?\195?\169solution des chemins pour les images dans JRSTUserAgent. Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-23 15:26:30 UTC (rev 670) +++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-24 08:44:53 UTC (rev 671) @@ -123,21 +123,12 @@ return new URL(uri).toString(); } catch (MalformedURLException e) { XRLog.load("Could not read " + uri + " as a URL; may be relative. Testing using parent URL " + path); - String ResourcePath = path; try { - // Transforms relative path to use it after - if (uri.startsWith(THIS_DIRECTORY)) { - uri = uri.replace(THIS_DIRECTORY, ""); - } else if ((uri.startsWith(PREVIOUS_DIRECTORY))) { - while (uri.startsWith(PREVIOUS_DIRECTORY)) { - uri = uri.replace(PREVIOUS_DIRECTORY, ""); - // ResourcePath becomes the path of the parent directory - ResourcePath = path.substring(0, path.lastIndexOf("/", path.length()-2)); - ResourcePath = ResourcePath + "/"; - } - } + URI resourcePath = new URI(path); + resourcePath = resourcePath.resolve(uri); + // Builds the full resource path - File file = new File(ResourcePath + uri); + File file = new File(resourcePath.toString()); URL result = file.toURI().toURL(); ret = result.toString(); } catch (Exception e1) {