File tree 2 files changed +16
-3
lines changed
main/java/pl/edu/icm/unity/engine/api/utils
test/java/pl/edu/icm/unity/engine/api/utils
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ public static URIBuilder newInstance(URI uri)
28
28
{
29
29
URIBuilder builder = new URIBuilder (uri );
30
30
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 ))
32
34
.collect (Collectors .toList ());
33
35
builder .clearParameters ();
34
36
builder .addParameters (fixedParams );
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public class TestURIBuilderFixer
21
21
@ Test
22
22
public void shouldParseStringWithPlusEncodedSpaceInPath () throws URISyntaxException
23
23
{
24
- URIBuilder builder = new URIBuilder ("foo://some/path:name+ooo" );
24
+ URIBuilder builder = URIBuilderFixer . newInstance ("foo://some/path:name+ooo" );
25
25
builder .addParameter ("p" , "val" );
26
26
URI uri = builder .build ();
27
27
@@ -52,10 +52,21 @@ public void shouldParseURIWithPlusEncodedSpaceInURIParam() throws URISyntaxExcep
52
52
@ Test
53
53
public void shouldParseURIWithPercentEncodedSpaceInParam () throws URISyntaxException
54
54
{
55
- URIBuilder builder = new URIBuilder ("https://some.domain.com?param1=aaa%20bbb" );
55
+ URIBuilder builder = URIBuilderFixer . newInstance ("https://some.domain.com?param1=aaa%20bbb" );
56
56
builder .addParameter ("p" , "val" );
57
57
URI uri = builder .build ();
58
58
59
59
assertThat (uri .toASCIIString ()).isEqualTo ("https://some.domain.com?param1=aaa%20bbb&p=val" );
60
60
}
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
+
61
72
}
You can’t perform that action at this time.
0 commit comments