Make HTTP scheme parsing case-insensitive
Issue: SPR-10779
This commit is contained in:
parent
1e90d02973
commit
4c991ba4d0
|
@ -60,7 +60,7 @@ public class UriComponentsBuilder {
|
|||
|
||||
private static final String SCHEME_PATTERN = "([^:/?#]+):";
|
||||
|
||||
private static final String HTTP_PATTERN = "(http|https):";
|
||||
private static final String HTTP_PATTERN = "(?i)(http|https):";
|
||||
|
||||
private static final String USERINFO_PATTERN = "([^@/]*)";
|
||||
|
||||
|
@ -223,7 +223,8 @@ public class UriComponentsBuilder {
|
|||
if (m.matches()) {
|
||||
UriComponentsBuilder builder = new UriComponentsBuilder();
|
||||
|
||||
builder.scheme(m.group(1));
|
||||
String scheme = m.group(1);
|
||||
builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme);
|
||||
builder.userInfo(m.group(4));
|
||||
builder.host(m.group(5));
|
||||
String port = m.group(7);
|
||||
|
|
|
@ -161,6 +161,14 @@ public class UriComponentsBuilderTests {
|
|||
assertEquals("1USD=?EUR", result.getQueryParams().getFirst("q"));
|
||||
}
|
||||
|
||||
// SPR-10779
|
||||
|
||||
@Test
|
||||
public void fromHttpUrlStringCaseInsesitiveScheme() {
|
||||
assertEquals("http", UriComponentsBuilder.fromHttpUrl("HTTP://www.google.com").build().getScheme());
|
||||
assertEquals("https", UriComponentsBuilder.fromHttpUrl("HTTPS://www.google.com").build().getScheme());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void path() throws URISyntaxException {
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/foo/bar");
|
||||
|
|
Loading…
Reference in New Issue