From 026eb88560a0321df6da87284c8e8ed2e1afc875 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 20 Nov 2009 15:55:51 +0300 Subject: [PATCH] artifact editor: trim slashes when adding to classpath --- .../openapi/deployment/DeploymentUtil.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java b/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java index 7525b2f08fb0..eada13236fc9 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java +++ b/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java @@ -69,11 +69,20 @@ public abstract class DeploymentUtil { return builder.toString(); } - public static String appendToPath(@NotNull String path, @NotNull String name) { - if (!StringUtil.endsWithChar(path, '/') && !path.endsWith(File.separator)) { - path += "/"; + public static String appendToPath(@NotNull String basePath, @NotNull String relativePath) { + final boolean endsWithSlash = StringUtil.endsWithChar(basePath, '/') || StringUtil.endsWithChar(basePath, '\\'); + final boolean startsWithSlash = StringUtil.startsWithChar(relativePath, '/') || StringUtil.startsWithChar(relativePath, '\\'); + String tail; + if (endsWithSlash && startsWithSlash) { + tail = trimForwardSlashes(relativePath); } - return path + trimForwardSlashes(name); + else if (!endsWithSlash && !startsWithSlash && basePath.length() > 0 && relativePath.length() > 0) { + tail = "/" + relativePath; + } + else { + tail = relativePath; + } + return basePath + tail; } public abstract BuildRecipe createBuildRecipe();