use strings.TrimPrefix instead of Replace when checking paths

This commit is contained in:
Christian Rocha 2020-09-07 15:01:34 -04:00 committed by Christian Muehlhaeuser
commit f8fa5a04dc

View file

@ -10,7 +10,7 @@ import (
// in a dot directory and browsing files beneath this function won't return
// true every time.
func isDotFileOrDir(cwd, path string) bool {
p := strings.Replace(path, cwd, "", 1)
p := strings.TrimPrefix(path, cwd)
for _, v := range strings.Split(p, string(os.PathSeparator)) {
if len(v) > 0 && v[0] == '.' {
return true