Skip to content

Commit

Permalink
fix: support double curly braces
Browse files Browse the repository at this point in the history
  • Loading branch information
yzerk committed Apr 26, 2023
1 parent 0b9905f commit eedfdbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class FileMatcher implements PathMatcher {
}
pattern = pattern.replaceAll("\\\\+", Utils.PATH_SEPARATOR_REGEX + Utils.PATH_SEPARATOR_REGEX);
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 @@ -78,6 +78,17 @@ public void testNpe() {
"FileHelper should throw NPE in filterOutIgnoredFiles");
}

@Test
public void testFilterSourcesWithSpecialSymbols() {
List<File> sources = new ArrayList<>();
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"));
FileHelper fileHelper = new FileHelper(project.getBasePath());
List<File> actualResult = fileHelper.filterOutIgnoredFiles(sources, Arrays.asList(".*"));
assertEquals(sources, actualResult);
}

@Test
public void testGetFiles_WrongBasePath() {
FileHelper fileHelper = new FileHelper(project.getBasePath() + "non_existent_folder");
Expand Down

0 comments on commit eedfdbf

Please sign in to comment.