Skip to content

Commit 0aca5b9

Browse files
committed
Handle empty and slash-prefixed URIs in apply() method
- Updated RootUriTemplateHandler.apply() to: - Prefix rootUri if uriTemplate starts with '/' - Return rootUri if uriTemplate is blank - This ensures correct behavior for empty and relative paths
1 parent 811ddcd commit 0aca5b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

module/spring-boot-restclient/src/main/java/org/springframework/boot/restclient/RootUriTemplateHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
* @author Phillip Webb
3232
* @author Scott Frederick
33+
* @author Hyunwoo Gu
3334
* @since 4.0.0
3435
*/
3536
public class RootUriTemplateHandler implements UriTemplateHandler {
@@ -64,7 +65,9 @@ public URI expand(String uriTemplate, @Nullable Object... uriVariables) {
6465
String apply(String uriTemplate) {
6566
String rootUri = getRootUri();
6667
if (rootUri != null && StringUtils.startsWithIgnoreCase(uriTemplate, "/")) {
67-
return getRootUri() + uriTemplate;
68+
return rootUri + uriTemplate;
69+
} else if (rootUri != null && uriTemplate.isBlank()) {
70+
return rootUri;
6871
}
6972
return uriTemplate;
7073
}

0 commit comments

Comments
 (0)