JCLOUDS-1443: fix(rest/processor): check if `/` is ending a default endpoint

This commit is contained in:
Mathieu Tortuyaux 2018-08-20 14:55:47 -04:00 committed by Ignasi Barrera
parent cf67233765
commit bcc6a26488
2 changed files with 10 additions and 1 deletions

View File

@ -573,7 +573,9 @@ public class RestAnnotationProcessor implements Function<Invocation, HttpRequest
return null;
if (original.getHost() != null)
return original;
return withHost.resolve(original);
String host = withHost.toString();
URI baseURI = host.endsWith("/") ? withHost : URI.create(host + "/");
return baseURI.resolve(original);
}
private org.jclouds.rest.MapBinder getMapPayloadBinderOrNull(Invocation invocation) {

View File

@ -2679,6 +2679,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
assertEquals(new URI("http://foo/bar"), result);
}
@Test
public void testComplexHost() throws Exception {
URI result = RestAnnotationProcessor.addHostIfMissing(new URI("bar"), new URI("http://foo/foobar"));
assertEquals(new URI("http://foo/foobar/bar"), result);
}
DateService dateService = new SimpleDateFormatDateService();
RestAnnotationProcessor processor;
TransformerForRequest transformer;