Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Allow whitespace in mappingV2 rules #781

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading