Skip to content

Commit

Permalink
Allow whitespace in mappingV2 rules (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
aprudhomme authored Nov 6, 2024
1 parent 5fab5ab commit ce5ced1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private List<String> extractRules(String mappings, String separator) {
return Arrays.asList(mappings.split(separator));
}

static Pattern p = Pattern.compile("(.*)\\s*=>\\s*(.*)\\s*$");
static Pattern p = Pattern.compile("(.*)=>(.*)$");

protected void parseRules(List<String> rules, NormalizeCharMap.Builder builder) {
for (String rule : rules) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public void testDifferentSeparator() throws IOException {
assertEquals("abc and d n e'n'f g hi", output);
}

@Test
public void testWhitespaceInRule() throws IOException {
MappingV2CharFilterFactory factory = getFactory(". =>|,=> ");
String output = getFiltered(factory, "this. is, a test, string");
assertEquals("thisis a test string", output);
}

@Test
public void testNoMappings() {
try {
Expand Down

0 comments on commit ce5ced1

Please sign in to comment.