Normalize paths to forward slashes

Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
Hidde Beydals
2021-04-08 16:38:37 +02:00
parent 5a67f94380
commit e0dd12505f
5 changed files with 12 additions and 8 deletions

View File

@ -18,6 +18,7 @@ package flags
import (
"fmt"
"path/filepath"
"strings"
securejoin "github.com/cyphar/filepath-securejoin"
@ -29,6 +30,10 @@ func (p *SafeRelativePath) String() string {
return string(*p)
}
func (p *SafeRelativePath) ToSlash() string {
return filepath.ToSlash(p.String())
}
func (p *SafeRelativePath) Set(str string) error {
// The result of secure joining on a relative base dir is a flattened relative path.
cleanP, err := securejoin.SecureJoin("./", strings.TrimSpace(str))