aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2022-08-08 15:44:23 +0200
committersonartech <sonartech@sonarsource.com>2022-08-09 20:03:18 +0000
commit64ad3061e8f8ecad6bbdb9b0af267cbe885a2f19 (patch)
treea27c5eda57591c78cbabdc40506f1ea8f9ea226f
parent16ba3f5dffaf8bc835422584330c0902d4f4452e (diff)
downloadsonarqube-64ad3061e8f8ecad6bbdb9b0af267cbe885a2f19.tar.gz
sonarqube-64ad3061e8f8ecad6bbdb9b0af267cbe885a2f19.zip
SONAR-17150 fix SSF-39
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java5
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/platform/UrlSettingsTest.java3
2 files changed, 3 insertions, 5 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 97c0322ff30..72f657de8c4 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
@@ -26,6 +26,7 @@ import org.sonar.api.server.ServerSide;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
+import static org.apache.commons.lang.StringUtils.stripEnd;
import static org.sonar.api.CoreProperties.SERVER_BASE_URL;
import static org.sonar.process.ProcessProperties.Property.WEB_CONTEXT;
import static org.sonar.process.ProcessProperties.Property.WEB_HOST;
@@ -43,9 +44,7 @@ public class UrlSettings {
public UrlSettings(Configuration config) {
this.config = config;
- this.contextPath = config.get(WEB_CONTEXT.getKey()).orElse("")
- // Remove trailing slashes
- .replaceFirst("(\\/+)$", "");
+ this.contextPath = stripEnd(config.get(WEB_CONTEXT.getKey()).orElse(""), "/");
}
public String getBaseUrl() {
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 edd166e66da..cbef143fbcd 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
@@ -35,8 +35,7 @@ public class UrlSettingsTest {
private static final String PORT_PORPERTY = "sonar.web.port";
private static final String CONTEXT_PROPERTY = "sonar.web.context";
-
- private MapSettings settings = new MapSettings(new PropertyDefinitions(System2.INSTANCE, CorePropertyDefinitions.all()));
+ private final MapSettings settings = new MapSettings(new PropertyDefinitions(System2.INSTANCE, CorePropertyDefinitions.all()));
@Test
public void use_default_context_path() {