]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12760 remove trailing slash in gitlab url setting
authorPierre Guillot <pierre.guillot@sonarsource.com>
Fri, 29 Nov 2019 10:13:22 +0000 (11:13 +0100)
committerSonarTech <sonartech@sonarsource.com>
Fri, 29 Nov 2019 19:46:11 +0000 (20:46 +0100)
server/sonar-auth-gitlab/src/main/java/org/sonar/auth/gitlab/GitLabSettings.java
server/sonar-auth-gitlab/src/test/java/org/sonar/auth/gitlab/GitLabSettingsTest.java

index 7eb6c23670f7e304874fd7d22eb8288151b2ceb2..9dbc7a61e9144ac0649342cdbb6631ae32439bb7 100644 (file)
@@ -48,7 +48,11 @@ public class GitLabSettings {
   }
 
   public String url() {
-    return configuration.get(GITLAB_AUTH_URL).orElse(null);
+    String url = configuration.get(GITLAB_AUTH_URL).orElse(null);
+    if (url != null && url.endsWith("/")) {
+      return url.substring(0, url.length() - 1);
+    }
+    return url;
   }
 
   public String applicationId() {
index b73fe1826a2a724bf1c7ed7e4474088e5ab88dd2..aeff42d7fdb740170a54e56275a5fcc14f1371d2 100644 (file)
@@ -51,6 +51,11 @@ public class GitLabSettingsTest {
   @Test
   public void test_settings() {
     assertThat(config.url()).isEqualTo("https://gitlab.com");
+
+    settings.setProperty(GITLAB_AUTH_URL, "https://gitlab.com/api/");
+    assertThat(config.url()).isEqualTo("https://gitlab.com/api");
+
+
     settings.setProperty(GITLAB_AUTH_URL, "https://gitlab.com/api");
     assertThat(config.url()).isEqualTo("https://gitlab.com/api");