Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
Fix relative path finding (gobuffalo/buffalo#982) (#55)
Browse files Browse the repository at this point in the history
strings.TrimPrefix can give the wrong result with case-insensitive
paths. filepath.Rel usually works better.
  • Loading branch information
egonelbre authored and markbates committed Mar 25, 2018
1 parent 09d0f14 commit 3402a16
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion box.go
Expand Up @@ -158,7 +158,10 @@ func (b Box) Walk(wf WalkFunc) error {
return errors.WithStack(err)
}
return filepath.Walk(base, func(path string, info os.FileInfo, err error) error {
cleanName := strings.TrimPrefix(path, base)
cleanName, err := filepath.Rel(base, path)
if err != nil {
cleanName = strings.TrimPrefix(path, base)
}
cleanName = filepath.ToSlash(filepath.Clean(cleanName))
cleanName = strings.TrimPrefix(cleanName, "/")
cleanName = filepath.FromSlash(cleanName)
Expand Down

0 comments on commit 3402a16

Please sign in to comment.