fix parsing query string

This commit is contained in:
Naoyuki Kanezawa
2015-05-06 23:54:21 +09:00
parent b92b560c36
commit d79d63c747
2 changed files with 7 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ public class ParseQS {
for (String _pair : pairs) {
String[] pair = _pair.split("=");
qry.put(Global.decodeURIComponent(pair[0]),
pair.length > 0 ? Global.decodeURIComponent(pair[1]) : "");
pair.length > 1 ? Global.decodeURIComponent(pair[1]) : "");
}
return qry;
}

View File

@@ -25,6 +25,12 @@ public class ParseQSTest {
queryObject = ParseQS.decode("india=new%20delhi");
assertThat(queryObject.get("india"), is("new delhi"));
queryObject = ParseQS.decode("woot=");
assertThat(queryObject.get("woot"), is(""));
queryObject = ParseQS.decode("woot");
assertThat(queryObject.get("woot"), is(""));
}
@Test