Skip to content

Commit

Permalink
use constants
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina20 committed Dec 17, 2023
1 parent 019a024 commit d7704f8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/com/crowdin/cli/utils/PlaceholderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ public class PlaceholderUtil {
public static final String ESCAPE_ROUND_BRACKET_OPEN = isWindows() ? "^(" : "\\(";
public static final String ESCAPE_ROUND_BRACKET_CLOSE = isWindows() ? "^)" : "\\)";
private static final String ESCAPE_DOT = isWindows() ? "^." : "\\.";
private static final String ESCAPE_DOT_REGEX = "\\.";
private static final String ESCAPE_DOT_PLACEHOLDER = "{ESCAPE_DOT}";
private static final String ESCAPE_QUESTION = isWindows() ? "^?" : "\\?";
private static final String ESCAPE_QUESTION_REGEX = "\\?";
private static final String ESCAPE_QUESTION_PLACEHOLDER = "{ESCAPE_QUESTION_MARK}";
private static final String ESCAPE_ASTERISK = isWindows() ? "^*" : "\\*";
private static final String ESCAPE_ASTERISK_REGEX = "\\*";
private static final String ESCAPE_ASTERISK_PLACEHOLDER = "{ESCAPE_ASTERISK}";
private static final String ESCAPE_ASTERISK_REPLACEMENT_FROM = ".+" + Utils.PATH_SEPARATOR;
private static final String ESCAPE_ASTERISK_REPLACEMENT_TO = "(.+" + Utils.PATH_SEPARATOR_REGEX + ")?";
Expand Down Expand Up @@ -236,7 +239,7 @@ public static String formatSourcePatternForRegex(String toFormat) {
}
toFormat = toFormat
.replace(ESCAPE_DOT, ESCAPE_DOT_PLACEHOLDER)
.replace(DOT, "\\.")
.replace(DOT, ESCAPE_DOT_REGEX)
.replace(ESCAPE_DOT_PLACEHOLDER, ESCAPE_DOT)

.replace(ESCAPE_QUESTION, ESCAPE_QUESTION_PLACEHOLDER)
Expand All @@ -259,9 +262,9 @@ public static String formatSourcePatternForRegex(String toFormat) {

if (isWindows()) {
toFormat = toFormat
.replace(ESCAPE_ASTERISK, "\\*")
.replace(ESCAPE_DOT, "\\.")
.replace(ESCAPE_QUESTION, "\\?");
.replace(ESCAPE_ASTERISK, ESCAPE_ASTERISK_REGEX)
.replace(ESCAPE_DOT, ESCAPE_DOT_REGEX)
.replace(ESCAPE_QUESTION, ESCAPE_QUESTION_REGEX);

Check warning on line 267 in src/main/java/com/crowdin/cli/utils/PlaceholderUtil.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/crowdin/cli/utils/PlaceholderUtil.java#L264-L267

Added lines #L264 - L267 were not covered by tests
}
return toFormat
.replace(PLACEHOLDER_FILE_EXTENSION, "[^/]+")
Expand Down

0 comments on commit d7704f8

Please sign in to comment.