Skip to content

Commit

Permalink
Fix query param parsing when there is no value
Browse files Browse the repository at this point in the history
  • Loading branch information
sangupta committed Mar 20, 2017
1 parent 3bd0e69 commit e10f804
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/com/sangupta/jerry/util/UrlManipulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,13 @@ private void extractDomainAndPort(String url, int start, int end) {
* the key value pairs from this segment of the url.
*
* @param url
* the url from which query paramters need to be extracted
* the url from which query parameters need to be extracted
*
* @param start
* the starting index for query parameters
*
* @param end
* the ending index for query paramets
* the ending index for query parameters
*
*/
private void extractQueryParams(String url, int start, int end) {
Expand All @@ -632,6 +632,16 @@ private void extractQueryParams(String url, int start, int end) {
String[] tokens = segment.split("&");
for(String token : tokens) {
String[] pair = token.split("=");

if(pair.length == 1) {
// this is just a parameter with the param name
// the value can be assumed to be empty
this.queryParams.put(token, StringUtils.EMPTY_STRING);
return;
}

// in this case the query params have multiple '=' signs
// some problem in parsing these values
if(pair.length != 2) {
throw new IllegalArgumentException("Query parameter is not a valid pair: " + token);
}
Expand Down

0 comments on commit e10f804

Please sign in to comment.