From 75bc3bd6d797de54f64e367b0851de5f99474fd6 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 8 Jul 2011 21:09:13 +0200 Subject: [PATCH] fix bug in HttpUtil.getCompleteUrl --- .../main/java/sonia/scm/util/HttpUtil.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scm-core/src/main/java/sonia/scm/util/HttpUtil.java b/scm-core/src/main/java/sonia/scm/util/HttpUtil.java index 724cbc4fef..688d313640 100644 --- a/scm-core/src/main/java/sonia/scm/util/HttpUtil.java +++ b/scm-core/src/main/java/sonia/scm/util/HttpUtil.java @@ -88,13 +88,13 @@ public class HttpUtil * Url folder separator * @since 1.5 */ - public static final char SEPARATOR_FOLDER = '/'; + public static final String SEPARATOR_PATH = "/"; /** * Url port separator * @since 1.5 */ - public static final char SEPARATOR_PORT = ':'; + public static final String SEPARATOR_PORT = ":"; /** * Url scheme separator @@ -132,24 +132,29 @@ public class HttpUtil //~--- get methods ---------------------------------------------------------- /** - * Method description + * Return the complete url of the given path. * * - * @param configuration - * @param path + * @param configuration - main SCM-Manager configuration + * @param path to get the url from * - * @return * @since 1.5 + * + * @return the complete url of the given path */ public static String getCompleteUrl(ScmConfiguration configuration, String path) { String url = configuration.getBaseUrl(); - if (url.endsWith("/") && path.startsWith("/")) + if (url.endsWith(SEPARATOR_PATH) && path.startsWith(SEPARATOR_PATH)) { url = url.substring(0, url.length()); } + else if (!path.startsWith(SEPARATOR_PATH)) + { + path = SEPARATOR_PATH.concat(path); + } return url.concat(path); } @@ -176,7 +181,7 @@ public class HttpUtil if (portIndex > 0) { String portString = urlWithoutScheme.substring(portIndex + 1); - int slIndex = portString.indexOf(SEPARATOR_FOLDER); + int slIndex = portString.indexOf(SEPARATOR_PATH); if (slIndex > 0) {