From b6a204f5bd96632664372f073a6dac75da37a39d Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Mon, 28 Dec 2020 15:20:09 +0000 Subject: [PATCH] Escape illegal filename characters in Windows --- src/rename.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rename.cr b/src/rename.cr index 59fd645..1fc7693 100644 --- a/src/rename.cr +++ b/src/rename.cr @@ -139,9 +139,13 @@ module Rename post_process str end + # Post-processes the generated file/folder name + # - Handles the rare case where the string is `..` + # - Removes trailing spaces and periods + # - Replace illegal characters with `_` private def post_process(str) return "_" if str == ".." - str.gsub "/", "_" + str.rstrip(" .").gsub /[\/?<>\\:*|"^]/, "_" end end end