Skip to content

Commit

Permalink
Fix bug to read sub string correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sarankk authored and vietj committed Jan 15, 2025
1 parent e1e2a34 commit be97446
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public VariableAwareExpression(String value) {
int openingCurlyBracePos = value.indexOf("{", currentPos);
if (openingCurlyBracePos == -1) {
if (currentPos < value.length()) {
String authorizationPart = value.substring(currentPos, value.length() - currentPos);
String authorizationPart = value.substring(currentPos);
tmpParts.add(ctx -> authorizationPart);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,32 @@ public void test1() {
String resolved = expression.resolve(MultiMap.caseInsensitiveMultiMap().add("foo", "bar"));
assertEquals("bar", resolved);
}

@Test
public void test2() {
VariableAwareExpression expression = new VariableAwareExpression("{bar}end");
String resolved = expression.resolve(MultiMap.caseInsensitiveMultiMap().add("bar", "foo"));
assertEquals("fooend", resolved);
}

@Test
public void test3() {
VariableAwareExpression expression = new VariableAwareExpression("begin{bar}");
String resolved = expression.resolve(MultiMap.caseInsensitiveMultiMap().add("bar", "foo"));
assertEquals("beginfoo", resolved);
}

@Test
public void test4() {
VariableAwareExpression expression = new VariableAwareExpression("part1,part2{bar}");
String resolved = expression.resolve(MultiMap.caseInsensitiveMultiMap().add("bar", "foo"));
assertEquals("part1,part2foo", resolved);
}

@Test
public void test5() {
VariableAwareExpression expression = new VariableAwareExpression("part1{bar}part2,part3");
String resolved = expression.resolve(MultiMap.caseInsensitiveMultiMap().add("bar", "foo"));
assertEquals("part1foopart2,part3", resolved);
}
}

0 comments on commit be97446

Please sign in to comment.