tpl/path: Add path.Clean

Fixes #8885
This commit is contained in:
Brad
2021-10-05 10:15:10 -04:00
committed by GitHub
parent ecf025f006
commit e55466ce70
2 changed files with 41 additions and 0 deletions

View File

@@ -144,3 +144,15 @@ func (ns *Namespace) Join(elements ...interface{}) (string, error) {
}
return _path.Join(pathElements...), nil
}
// Clean replaces the separators used with standard slashes and then
// extraneous slashes are removed.
func (ns *Namespace) Clean(path interface{}) (string, error) {
spath, err := cast.ToStringE(path)
if err != nil {
return "", err
}
spath = filepath.ToSlash(spath)
return _path.Clean(spath), nil
}