@@ -9,6 +9,7 @@ public class FileNameFormatter {
99 private static final String PART_JOINER = "_" ;
1010
1111 private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter .ofPattern ("yyyy-MM-dd" );
12+ private static final String SLASH_REPLACEMENT = "_" ;
1213
1314 private FileNameFormatter () {
1415
@@ -19,18 +20,26 @@ public static String formatWithTimestampedContext(LocalDate timestamp, String pr
1920 String experimentPart , String type , String extension ) {
2021 return DATE_FORMATTER .format (timestamp )
2122 + PART_JOINER
22- + replaceSpaces (projectPart )
23+ + replaceForbiddenCharacters (projectPart )
2324 + PART_JOINER
24- + replaceSpaces (experimentPart )
25+ + replaceForbiddenCharacters (experimentPart )
2526 + PART_JOINER
26- + replaceSpaces (type )
27- + "." + replaceSpaces (extension );
27+ + replaceForbiddenCharacters (type )
28+ + "." + replaceForbiddenCharacters (extension );
29+ }
30+
31+ private static String replaceForbiddenCharacters (String input ) {
32+ return replaceSlashes (replaceSpaces (input ));
2833 }
2934
3035 private static String replaceSpaces (String projectPart ) {
3136 return projectPart .replaceAll ("\\ s" , SPACE_REPLACEMENT );
3237 }
3338
39+ private static String replaceSlashes (String input ) {
40+ return input .replace ("/" , SLASH_REPLACEMENT );
41+ }
42+
3443 public static String formatWithVersion (String filename , int version ,
3544 String extension ) {
3645 return replaceSpaces (filename ) + "_" + "v" + version + "." + replaceSpaces (extension );
0 commit comments