-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a linter for filenames when using ouput-dir
- Loading branch information
1 parent
a9bf2e2
commit 88d0a97
Showing
2 changed files
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package pkg | ||
|
||
import "strings" | ||
|
||
// SanitizeFilename replaces characters that are not allowed in filenames with underscores. | ||
func SanitizeFilename(filename string) string { | ||
// Define a set of characters that are not allowed in filenames. | ||
invalidChars := []string{"/", "\\", ":", "*", "?", "\"", "<", ">", "|"} | ||
|
||
// Replace each invalid character with an underscore. | ||
for _, char := range invalidChars { | ||
filename = strings.ReplaceAll(filename, char, "_") | ||
} | ||
return filename | ||
} |