#369 - Traverson no defensively expands URIs handed to getAndFindLinkWithRel(…).
This commit is contained in:
@@ -79,6 +79,15 @@ public class Hop {
|
||||
return new Hop(rel, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the {@link Hop} has parameters declared.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean hasParameters() {
|
||||
return !this.parameters.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Map} starting with the supplied template parameters. Then add the ones for this hop. This
|
||||
* allows a local hop to override global parameters.
|
||||
|
||||
@@ -391,8 +391,9 @@ public class Traverson {
|
||||
}
|
||||
|
||||
HttpEntity<?> request = prepareRequest(headers);
|
||||
UriTemplate template = new UriTemplate(uri);
|
||||
|
||||
ResponseEntity<String> responseEntity = operations.exchange(uri, GET, request, String.class);
|
||||
ResponseEntity<String> responseEntity = operations.exchange(template.expand(), GET, request, String.class);
|
||||
MediaType contentType = responseEntity.getHeaders().getContentType();
|
||||
String responseBody = responseEntity.getBody();
|
||||
|
||||
@@ -409,7 +410,7 @@ public class Traverson {
|
||||
/**
|
||||
* Don't expand if the parameters are empty
|
||||
*/
|
||||
if (thisHop.getParameters().isEmpty()) {
|
||||
if (!thisHop.hasParameters()) {
|
||||
return getAndFindLinkWithRel(link.getHref(), rels);
|
||||
} else {
|
||||
return getAndFindLinkWithRel(link.expand(thisHop.getMergedParameters(templateParameters)).getHref(), rels);
|
||||
|
||||
Reference in New Issue
Block a user