Skip to content

Commit e5c22cf

Browse files
committed
Sanitize file name. Breaks on Windows
1 parent d53e6bb commit e5c22cf

File tree

1 file changed

+4
-1
lines changed
  • examples-java/src/main/java/com/embabel/example/crew/bookwriter

1 file changed

+4
-1
lines changed

examples-java/src/main/java/com/embabel/example/crew/bookwriter/BookWriter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ record BookWriterConfig(
9292

9393
public Path saveContent(Book book) {
9494
var dir = outputDirectory != null ? outputDirectory : System.getProperty("user.dir");
95-
var fileName = book.title().replace(" ", "_").toLowerCase() + ".md";
95+
var fileName = book.title()
96+
.replaceAll("[<>:\"|*?/\\\\]", "_")
97+
.replace(" ", "_")
98+
.toLowerCase() + ".md";
9699
return FileTools.readWrite(dir).createFile("books" + File.separator + fileName, book.text(), true);
97100
}
98101
}

0 commit comments

Comments
 (0)