Commits

Joe Clark committed a8f7dbc

Resolve issue #14 - handle trailing slash in Base URL when uploading plugin.

Comments (0)

Files changed (1)

src/main/java/com/atlassian/bamboo/plugins/confdeploy/UniversalPluginUploader.java

             // The "self" link in the JSON response will include any path component of the Base URL. Need to strip
             // this out of the configured Base URL when concatenating them or else the context path of the app will
             // get duplicated.
-            int slashPos = remoteHostBaseURL.lastIndexOf("/");
-            String baseUrlMinusPath = slashPos >= 8 ? remoteHostBaseURL.substring(0, slashPos) : remoteHostBaseURL;
+            String fixedRemoteHostBaseUrl = remoteHostBaseURL;
+            if (remoteHostBaseURL.endsWith("/"))
+                fixedRemoteHostBaseUrl = remoteHostBaseURL.substring(0, remoteHostBaseURL.length() - 2);
+
+            int slashPos = fixedRemoteHostBaseUrl.lastIndexOf("/");
+            String baseUrlMinusPath = slashPos >= 8 ? fixedRemoteHostBaseUrl.substring(0, slashPos) : fixedRemoteHostBaseUrl;
             poll(entity, baseUrlMinusPath, client);
         }
         catch (IOException e)