Skip to content

Commit

Permalink
handle code test
Browse files Browse the repository at this point in the history
  • Loading branch information
baomingyu committed Oct 18, 2024
1 parent 79ac582 commit 8f979c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,9 @@ public static List<Map<String, String>> splitKv(
switch (state) {
// match previous kv delimiter first when there are more than one kvDelimiter
case STATE_KEY:
if (i == 0) {
stringBuilder.append(ch);
} else {
key = stringBuilder.toString();
stringBuilder.setLength(0);
state = STATE_VALUE;
}
key = stringBuilder.toString();
stringBuilder.setLength(0);
state = STATE_VALUE;
break;
case STATE_VALUE:
stringBuilder.append(ch);
Expand Down Expand Up @@ -255,6 +251,7 @@ public static List<Map<String, String>> splitKv(
case STATE_VALUE:
value = stringBuilder.toString();
fields.put(key, value);
break;
case STATE_KEY:
if (lastKey != null) {
value = stringBuilder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void testSplitDanglingKey1() {
public void testSplitDanglingKey2() {
Map<String, String> kvMap = splitKv("f1&f2=3", '&',
'=', null, null);
Assert.assertEquals("3", kvMap.get("f2"));
Assert.assertEquals("3", kvMap.get("f1&f2"));
}

@Test
Expand Down

0 comments on commit 8f979c9

Please sign in to comment.