Skip to content

Commit

Permalink
fix: URIBuilder.getFirstQueryParam throws exception when query is emp…
Browse files Browse the repository at this point in the history
…ty. Instead it must return null if named parameter not found
  • Loading branch information
skssxf committed Dec 19, 2023
1 parent 030c132 commit c4ec335
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ public List<NameValuePair> getQueryParams() {
* @since 5.2
*/
public NameValuePair getFirstQueryParam(final String name) {
return queryParams.stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null);
return getQueryParams().stream().filter(e -> name.equals(e.getName())).findFirst().orElse(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ public void testGetFirstNamedParameter() throws Exception {
//
uribuilder = new URIBuilder("http://localhost:80/?param=some%20other%20stuff&blah=blah&blah=blah2");
Assertions.assertEquals("blah", uribuilder.getFirstQueryParam("blah").getValue());
uribuilder.removeQuery();
Assertions.assertNull(uribuilder.getFirstQueryParam("param"));
}

@Test
Expand Down

0 comments on commit c4ec335

Please sign in to comment.