Skip to content

Commit

Permalink
Fix query param in UriBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol committed Oct 19, 2023
1 parent ab217b3 commit cd910d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ private static String createURI(
offset, encode, mapValues, sb);
if (sb.length() > sbLength) {
char firstQuery = sb.charAt(sbLength);
if (firstQuery != '?' && firstQuery != '&') {
if (firstQuery != '?' && (!query.trim().startsWith("{") || firstQuery != '&')) {
sb.insert(sbLength, '?');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,17 @@ public void testQueryParamStyleMultiPairs() {
"key1=val1&key1=val2&key2=val1&key1=val3");
}


@Test
public void testQueryParam() {
URI uri = new JerseyUriBuilder().scheme("http").host("localhost").port(8080).uri("some")
.replacePath("NewPath")
.replaceQuery("&Second")
.build();
Assertions.assertEquals("&Second", uri.getQuery());
}


@Test
void testFragment5269() throws URISyntaxException {
final URI uri = new URI("http://www.example.org/foo.xml#xpointer(//Rube)").normalize();
Expand Down

0 comments on commit cd910d7

Please sign in to comment.