Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
fix backslash to slash substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
aaperis committed Apr 21, 2023
1 parent 51f8163 commit b4a35fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ func TLScertToFile(filename string, derBytes []byte) error {
func FormatUploadFilePath(filePath string) (string, error) {

// Check for mixed "\" and "/" in filepath. Stop and throw an error if true so that
// we do not end up with unintended folder structure when applying ToSlash later on
// we do not end up with unintended folder structure when applying ReplaceAll below
if strings.Contains(filePath, "\\") && strings.Contains(filePath, "/") {
return filePath, fmt.Errorf("filepath contains mixed '\\' and '/' characters")
}

// make path separators os compatible
outPath := filepath.ToSlash(filePath)
// make any windows path separators linux compatible
outPath := strings.ReplaceAll(filePath, "\\", "/")

// [\x00-\x1F\x7F] is the control character set
re := regexp.MustCompile(`[\\:\*\?"<>\|\x00-\x1F\x7F]`)
Expand Down

0 comments on commit b4a35fe

Please sign in to comment.