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 <[email protected]>
  • Loading branch information
jansupol committed Oct 20, 2023
1 parent ab217b3 commit 4de6bee
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().charAt(0) != '{' || 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 4de6bee

Please sign in to comment.