ensure getRawQuery is not null before appending
Motivation: without this check then given a URI with path /path the resulting URL will be /path?null= Modifications: check that getRawQuery doesn't return null and only append if not Result: urls of the form /path will not have a null?= appended
This commit is contained in:
parent
f86356f083
commit
2c08c4a553
@ -159,7 +159,7 @@ public class QueryStringDecoder {
|
||||
hasPath = false;
|
||||
}
|
||||
// Also take care of cut of things like "http://localhost"
|
||||
this.uri = rawPath + '?' + uri.getRawQuery();
|
||||
this.uri = rawPath + (uri.getRawQuery() == null? "" : '?' + uri.getRawQuery());
|
||||
|
||||
this.charset = charset;
|
||||
this.maxParams = maxParams;
|
||||
|
@ -20,6 +20,7 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -27,6 +28,12 @@ import java.util.Map.Entry;
|
||||
|
||||
public class QueryStringDecoderTest {
|
||||
|
||||
@Test
|
||||
public void testBasicUris() throws URISyntaxException {
|
||||
QueryStringDecoder d = new QueryStringDecoder(new URI("http://localhost/path"));
|
||||
Assert.assertEquals(0, d.parameters().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
QueryStringDecoder d;
|
||||
|
Loading…
Reference in New Issue
Block a user