Skip to content

Commit

Permalink
Merge pull request #350 from crowdin/fix-source-search
Browse files Browse the repository at this point in the history
Fix for searching files
  • Loading branch information
andrii-bodnar authored Mar 17, 2021
2 parents 1b2145d + a308d09 commit 3191741
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class FileHelper {

private static final String ESCAPE_ASTERISK_PLACEHOLDER = "{ESCAPE_ASTERISK}";

private static final String PLUS = "+";

private static final String ESCAPE_PLUS = "\\+";

private final String basePath;

public FileHelper(String basePath) {
Expand Down Expand Up @@ -127,6 +131,8 @@ private String translateToRegex(String node) {
.replace(ESCAPE_QUESTION, ESCAPE_QUESTION_PLACEHOLDER)
.replace(QUESTION_MARK, DOT)
.replace(ESCAPE_QUESTION_PLACEHOLDER, ESCAPE_QUESTION);
node = node
.replace(PLUS, ESCAPE_PLUS);
node = node
.replace(ESCAPE_ASTERISK, ESCAPE_ASTERISK_PLACEHOLDER)
.replace(ASTERISK, DOT_PLUS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class FileHelperTest {
private static String f2 = Utils.normalizePath("f2/");
private static String f21 = Utils.normalizePath("f2/in1/");

private static String fintlicu = Utils.normalizePath("f+intl-icu.en.yaml");

private static String projectRoot = Utils.normalizePath("");

private static List<String> allFiles = Arrays.asList(a, ax, f1a, f1ax, f11a, f11ax, f2a, f2ax, f21a, f21ax);
Expand Down Expand Up @@ -111,7 +113,8 @@ static Stream<Arguments> testGetFiles() {
arguments(allFiles, Utils.normalizePath("?.*"), Arrays.asList(a, ax)),
arguments(allFiles, Utils.normalizePath("*"), Arrays.asList(a, ax, f1, f2)),
arguments(allFiles, Utils.normalizePath("f3/**/*"), Collections.EMPTY_LIST),
arguments(allFiles, Utils.normalizePath("/f1/**"), Arrays.asList(f1, f11))
arguments(allFiles, Utils.normalizePath("/f1/**"), Arrays.asList(f1, f11)),
arguments(Collections.singletonList(fintlicu), fintlicu, Arrays.asList(fintlicu))
);
}

Expand Down

0 comments on commit 3191741

Please sign in to comment.