Skip to content

Commit

Permalink
add support for square brackets in file paths (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecampestrini authored Sep 28, 2023
1 parent fdf9cec commit 4ff1f55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class FileMatcher implements PathMatcher {
pattern = pattern.replaceAll("/+", "/");
pattern = pattern.replaceAll("\\{\\{+", "\\\\{\\\\{");
pattern = pattern.replaceAll("}}+", "\\\\}\\\\}");
pattern = pattern.replaceAll("\\[+", "\\\\[");
pattern = pattern.replaceAll("]+", "\\\\]");


// We *could* implement exactly what's documented. The idea would be to implement something like
// Java's Globs.toRegexPattern but supporting only the documented syntax. Instead, we will use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void testFilterSourcesWithSpecialSymbols() {
sources.add(new File("/files/folder/sub/1.xml"));
sources.add(new File("/files/{{cookiecutter.module_name}}"));
sources.add(new File("/files/{{cookiecutter.module_name}}/1.xml"));
sources.add(new File("/files/[folder-sub]/1.xml"));
FileHelper fileHelper = new FileHelper(project.getBasePath());
List<File> actualResult = fileHelper.filterOutIgnoredFiles(sources, Arrays.asList(".*"));
assertEquals(sources, actualResult);
Expand Down Expand Up @@ -134,4 +135,4 @@ private static <E> List<E> addToList(List<E> list, E... toAdd) {
toReturn.addAll(Arrays.asList(toAdd));
return toReturn;
}
}
}

0 comments on commit 4ff1f55

Please sign in to comment.