@@ -9,6 +9,7 @@ public class FileNameFormatter {
9
9
private static final String PART_JOINER = "_" ;
10
10
11
11
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter .ofPattern ("yyyy-MM-dd" );
12
+ private static final String SLASH_REPLACEMENT = "_" ;
12
13
13
14
private FileNameFormatter () {
14
15
@@ -19,18 +20,26 @@ public static String formatWithTimestampedContext(LocalDate timestamp, String pr
19
20
String experimentPart , String type , String extension ) {
20
21
return DATE_FORMATTER .format (timestamp )
21
22
+ PART_JOINER
22
- + replaceSpaces (projectPart )
23
+ + replaceForbiddenCharacters (projectPart )
23
24
+ PART_JOINER
24
- + replaceSpaces (experimentPart )
25
+ + replaceForbiddenCharacters (experimentPart )
25
26
+ 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 ));
28
33
}
29
34
30
35
private static String replaceSpaces (String projectPart ) {
31
36
return projectPart .replaceAll ("\\ s" , SPACE_REPLACEMENT );
32
37
}
33
38
39
+ private static String replaceSlashes (String input ) {
40
+ return input .replace ("/" , SLASH_REPLACEMENT );
41
+ }
42
+
34
43
public static String formatWithVersion (String filename , int version ,
35
44
String extension ) {
36
45
return replaceSpaces (filename ) + "_" + "v" + version + "." + replaceSpaces (extension );
0 commit comments