diff options
Diffstat (limited to 'server/sonar-server-common')
-rw-r--r-- | server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java | 4 | ||||
-rw-r--r-- | server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java b/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java index d2d3cd300ee..94f00608de3 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java @@ -19,6 +19,7 @@ */ package org.sonar.server.platform; +import org.apache.commons.lang.StringUtils; import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.config.Configuration; import org.sonar.api.server.ServerSide; @@ -52,7 +53,8 @@ public class UrlSettings { if (isEmpty(url)) { url = computeBaseUrl(); } - return url; + // Remove trailing slashes + return StringUtils.removeEnd(url, "/"); } public String getContextPath() { diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java index e6ba2a0305c..c0c90874a76 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java @@ -58,6 +58,13 @@ public class UrlSettingsTest { } @Test + public void remove_trailing_slash() { + settings.setProperty("sonar.core.serverBaseURL", "http://mydomain.com/"); + + assertThat(underTest().getBaseUrl()).isEqualTo("http://mydomain.com"); + } + + @Test public void is_secured_on_https_server() { settings.setProperty("sonar.core.serverBaseURL", "https://mydomain.com"); |