Skip to content

Commit

Permalink
Simplify check
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
  • Loading branch information
gabriel-samfira committed Feb 10, 2023
1 parent d2c0e8a commit 2f4359c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions util/system/path_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) {
// whatever need exists.
// Alternatively, we could further validate the path and error out here, but that seems outside the
// scope of what this function should do.
parts := strings.SplitN(path, ":", 2)
if len(parts) == 1 || len(path) < 2 {
parts := strings.Split(path, ":")
if len(parts) != 2 {
return filepath.FromSlash(filepath.Clean(path)), nil
}

if !strings.EqualFold(parts[0], "c") {
return "", errors.New("The specified path is not on the system drive (C:)")
}
Expand Down

0 comments on commit 2f4359c

Please sign in to comment.