aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-07-31 14:52:34 +0200
committerSonarTech <sonartech@sonarsource.com>2018-08-02 20:21:33 +0200
commit13213988a1e5a88833cb70c2dedba51e70de154f (patch)
tree07896f5b6e515aed664b92ce9ef4831c43e34cf8 /server/sonar-server-common
parent4f4d0e0fc29c156393c42fd179495db301a928d0 (diff)
downloadsonarqube-13213988a1e5a88833cb70c2dedba51e70de154f.tar.gz
sonarqube-13213988a1e5a88833cb70c2dedba51e70de154f.zip
SONAR-11073 Remove trailing slash in "Server base URL"
To fix Bitbucket/GitHub oauth, and probably many other places
Diffstat (limited to 'server/sonar-server-common')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java7
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");