alist/pkg/utils/path.go

18 lines
396 B
Go
Raw Normal View History

2022-06-09 15:05:27 +00:00
package utils
import "strings"
// StandardizationPath convert path like '/' '/root' '/a/b'
func StandardizationPath(path string) string {
path = strings.TrimSuffix(path, "/")
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
return path
}
2022-06-11 06:43:03 +00:00
2022-06-13 06:53:44 +00:00
// PathEqual judge path is equal
2022-06-11 06:43:03 +00:00
func PathEqual(path1, path2 string) bool {
return StandardizationPath(path1) == StandardizationPath(path2)
}