If URI has no context path add one ("/")
Fixes gh-131
This commit is contained in:
@@ -85,6 +85,11 @@ public abstract class AbstractScmEnvironmentRepository implements EnvironmentRep
|
||||
while (uri.endsWith("/")) {
|
||||
uri = uri.substring(0, uri.length() - 1);
|
||||
}
|
||||
int index = uri.indexOf("://");
|
||||
if (index>0 && !uri.substring(index+"://".length()).contains("/")) {
|
||||
// If there's no context path add one
|
||||
uri = uri + "/";
|
||||
}
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.config.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -123,5 +122,17 @@ public class JGitEnvironmentRepositoryTests {
|
||||
assertEquals(repository.getUri() + "/bar.properties", environment
|
||||
.getPropertySources().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uriWithHostOnly() throws Exception {
|
||||
repository.setUri("git://localhost");
|
||||
assertEquals("git://localhost/", repository.getUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uriWithHostAndPath() throws Exception {
|
||||
repository.setUri("git://localhost/foo/");
|
||||
assertEquals("git://localhost/foo", repository.getUri());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user