Skip to content

Commit

Permalink
Sanitize pipe in var name (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini authored and wing328 committed Jul 5, 2018
1 parent b0cae23 commit 1d69566
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3631,6 +3631,9 @@ public String sanitizeName(String name, String removeCharRegEx) {
// input-name => input_name
name = name.replaceAll("-", "_");

// a|b => a_b
name = name.replace("|", "_");

// input name and age => input_name_and_age
name = name.replaceAll(" ", "_");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void convertVarName() throws Exception {
Assert.assertEquals(fakeJavaCodegen.toVarName("nam$$e"), "nam$$e");
Assert.assertEquals(fakeJavaCodegen.toVarName("user-name"), "userName");
Assert.assertEquals(fakeJavaCodegen.toVarName("user_name"), "userName");
Assert.assertEquals(fakeJavaCodegen.toVarName("user|name"), "userName");
}

@Test
Expand Down

0 comments on commit 1d69566

Please # to comment.