From dd34bd7595af62b4d6a3117ae9a0604b244bfa63 Mon Sep 17 00:00:00 2001 From: amorozov Date: Thu, 19 Sep 2024 17:27:13 +0300 Subject: [PATCH] feature: added ReplaceAllRestrictedCharactersNoSlashes method --- pkg/io/files/file_name_utils.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/io/files/file_name_utils.go b/pkg/io/files/file_name_utils.go index 03f22f6..5daf2c8 100644 --- a/pkg/io/files/file_name_utils.go +++ b/pkg/io/files/file_name_utils.go @@ -61,6 +61,17 @@ func ReplaceAllRestrictedCharacters(filePath string) string { return filePath } +func ReplaceAllRestrictedCharactersNoSlashes(filePath string) string { + for k, v := range RestrictedFilepathCharactersReplacements { + if k == "\\" || k == "/" { + continue + } + filePath = strings.ReplaceAll(filePath, k, v) + } + + return filePath +} + func TryAbs(filePath string) string { if !filepath.IsAbs(filePath) { abs, err := filepath.Abs(filePath)