File tree Expand file tree Collapse file tree
main/java/pl/edu/icm/unity/engine/api/utils
test/java/pl/edu/icm/unity/engine/api/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ public static URIBuilder newInstance(URI uri)
2828 {
2929 URIBuilder builder = new URIBuilder (uri );
3030 List <NameValuePair > fixedParams = builder .getQueryParams ().stream ()
31- .map (nvp -> new BasicNameValuePair (decodePlusIntoSpace (nvp .getName ()), decodePlusIntoSpace (nvp .getValue ())))
31+ .map (nvp -> new BasicNameValuePair (
32+ decodePlusIntoSpace (nvp .getName ()),
33+ nvp .getValue () != null ? decodePlusIntoSpace (nvp .getValue ()) : null ))
3234 .collect (Collectors .toList ());
3335 builder .clearParameters ();
3436 builder .addParameters (fixedParams );
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public class TestURIBuilderFixer
2121 @ Test
2222 public void shouldParseStringWithPlusEncodedSpaceInPath () throws URISyntaxException
2323 {
24- URIBuilder builder = new URIBuilder ("foo://some/path:name+ooo" );
24+ URIBuilder builder = URIBuilderFixer . newInstance ("foo://some/path:name+ooo" );
2525 builder .addParameter ("p" , "val" );
2626 URI uri = builder .build ();
2727
@@ -52,10 +52,21 @@ public void shouldParseURIWithPlusEncodedSpaceInURIParam() throws URISyntaxExcep
5252 @ Test
5353 public void shouldParseURIWithPercentEncodedSpaceInParam () throws URISyntaxException
5454 {
55- URIBuilder builder = new URIBuilder ("https://some.domain.com?param1=aaa%20bbb" );
55+ URIBuilder builder = URIBuilderFixer . newInstance ("https://some.domain.com?param1=aaa%20bbb" );
5656 builder .addParameter ("p" , "val" );
5757 URI uri = builder .build ();
5858
5959 assertThat (uri .toASCIIString ()).isEqualTo ("https://some.domain.com?param1=aaa%20bbb&p=val" );
6060 }
61+
62+ @ Test
63+ public void shouldParseURIWithValuelessParam () throws URISyntaxException
64+ {
65+ URIBuilder builder = URIBuilderFixer .newInstance ("https://some.domain.com?param1" );
66+ builder .addParameter ("p" , "val" );
67+ URI uri = builder .build ();
68+
69+ assertThat (uri .toASCIIString ()).isEqualTo ("https://some.domain.com?param1&p=val" );
70+ }
71+
6172}
You can’t perform that action at this time.
0 commit comments