Skip to content

Commit 751652d

Browse files
committed
Fixed IsInsideDir check
1 parent 743ef2f commit 751652d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

paths.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ func (p *Path) Clean() *Path {
167167
// IsInsideDir returns true if the current path is inside the provided
168168
// dir
169169
func (p *Path) IsInsideDir(dir *Path) (bool, error) {
170-
rel, err := filepath.Rel(p.path, dir.path)
170+
rel, err := filepath.Rel(dir.path, p.path)
171171
if err != nil {
172172
return false, err
173173
}
174-
return strings.Contains(rel, ".."+string(os.PathSeparator)) || rel == "..", nil
174+
return !strings.Contains(rel, ".."+string(os.PathSeparator)) && rel != ".." && rel != ".", nil
175175
}
176176

177177
// Parent returns all but the last element of path, typically the path's

0 commit comments

Comments
 (0)