Only non-null input resets scheme specific part

Closes gh-24444
This commit is contained in:
Rossen Stoyanchev
2020-01-30 06:16:43 +00:00
parent 688167a7df
commit cc4261c30b
2 changed files with 29 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -769,6 +769,21 @@ public class UriComponentsBuilderTests {
assertThat(uriComponents.getQueryParams().get("bar").get(0)).isNull();
}
@Test // gh-24444
public void opaqueUriDoesNotResetOnNullInput() throws URISyntaxException {
URI uri = new URI("urn:ietf:wg:oauth:2.0:oob");
UriComponents result = UriComponentsBuilder.fromUri(uri)
.host(null)
.port(-1)
.port(null)
.queryParams(null)
.replaceQuery(null)
.query(null)
.build();
assertThat(result.toUri()).isEqualTo(uri);
}
@Test
public void relativeUrls() {
String baseUrl = "https://example.com";