Skip to content

Commit

Permalink
escape backslashes
Browse files Browse the repository at this point in the history
  • Loading branch information
milesziemer committed Aug 9, 2024
1 parent 3bd4554 commit a97e5c2
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ public static PathMatcher getSmithyFilesPathMatcher(Project project) {
*/
public static String getBuildFilesWatchPattern(Project project) {
Path root = project.root();
String smithyBuildJsonPattern = root.resolve(ProjectConfigLoader.SMITHY_BUILD).toString();
String smithyProjectJsonPattern = root.resolve(ProjectConfigLoader.SMITHY_PROJECT).toString();
String smithyBuildJsonPattern = root.resolve(ProjectConfigLoader.SMITHY_BUILD)
.toString().replace("\\", "\\\\");
String smithyProjectJsonPattern = root.resolve(ProjectConfigLoader.SMITHY_PROJECT)
.toString().replace("\\", "\\\\");
List<String> patterns = new ArrayList<>();
patterns.add(smithyBuildJsonPattern);
patterns.add(smithyProjectJsonPattern);
for (String buildExt : ProjectConfigLoader.SMITHY_BUILD_EXTS) {
patterns.add(root.resolve(buildExt).toString());
patterns.add(root.resolve(buildExt).toString().replace("\\", "\\\\"));
}

return "{" + String.join(",", patterns) + "}";
Expand All @@ -97,7 +99,7 @@ public static PathMatcher getBuildFilesPathMatcher(Project project) {
private static String getSmithyFilePattern(Path path, boolean isWatcherPattern) {
String glob = path.toString();
if (glob.endsWith(".smithy") || glob.endsWith(".json")) {
return glob;
return glob.replace("\\", "\\\\");
}

if (!glob.endsWith(File.separator)) {
Expand All @@ -109,6 +111,6 @@ private static String getSmithyFilePattern(Path path, boolean isWatcherPattern)
glob += ".{smithy,json}";
}

return glob;
return glob.replace("\\", "\\\\");
}
}

0 comments on commit a97e5c2

Please sign in to comment.