Improve check whether to lowercase scheme

See gh-33715

```
Map has no value for 'thescheme'
java.lang.IllegalArgumentException: Map has no value for 'thescheme'
	at org.springframework.web.util.UriComponents$MapTemplateVariables.getValue(UriComponents.java:348)
	at org.springframework.web.util.UriComponents.expandUriComponent(UriComponents.java:263)
	at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:436)
	at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:53)
	at org.springframework.web.util.UriComponents.expand(UriComponents.java:161)
	at org.springframework.web.util.UriComponentsBuilder.buildAndExpand(UriComponentsBuilder.java:364)
```
This commit is contained in:
Yanming Zhou
2024-10-16 15:55:34 +08:00
committed by rstoyanchev
parent e89218b39a
commit f35ed8d044
2 changed files with 21 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Juergen Hoeller
* @author Sam Brannen
* @author David Eckel
* @author Yanming Zhou
*/
class UriComponentsBuilderTests {
@@ -637,6 +638,24 @@ class UriComponentsBuilderTests {
.buildAndExpand(Map.of("TheScheme", "ws"))
.toUri();
assertThat(uri.toString()).isEqualTo("ws://example.org");
uri = UriComponentsBuilder
.fromUriString("{TheScheme}s://example.org", parserType)
.buildAndExpand(Map.of("TheScheme", "ws"))
.toUri();
assertThat(uri.toString()).isEqualTo("wss://example.org");
uri = UriComponentsBuilder
.fromUriString("s{TheScheme}://example.org", parserType)
.buildAndExpand(Map.of("TheScheme", "ws"))
.toUri();
assertThat(uri.toString()).isEqualTo("sws://example.org");
uri = UriComponentsBuilder
.fromUriString("s{TheScheme}s://example.org", parserType)
.buildAndExpand(Map.of("TheScheme", "ws"))
.toUri();
assertThat(uri.toString()).isEqualTo("swss://example.org");
}
@ParameterizedTest