Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions private/pkg/normalpath/normalpath_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ func MapAllEqualOrContainingPathMap(m map[string]struct{}, path string, pathType
// also covers if path == separator.
n[pathRoot] = struct{}{}
}
for potentialMatch := range m {
for curPath := path; curPath != pathRoot; curPath = Dir(curPath) {
if potentialMatch == curPath {
n[potentialMatch] = struct{}{}
break
}
// Stop once every key has matched.
for curPath := path; curPath != pathRoot && len(n) < len(m); curPath = Dir(curPath) {
if _, ok := m[curPath]; ok {
n[curPath] = struct{}{}
}
}
return n
Expand Down
15 changes: 11 additions & 4 deletions private/pkg/normalpath/normalpath_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ func MapAllEqualOrContainingPathMap(m map[string]struct{}, path string, pathType
}

n := make(map[string]struct{})

for potentialMatch := range m {
if EqualsOrContainsPath(potentialMatch, path, pathType) {
n[potentialMatch] = struct{}{}
// Stop once every key has matched.
for curPath := path; len(n) < len(m); {
for potentialMatch := range m {
if strings.EqualFold(potentialMatch, curPath) {
n[potentialMatch] = struct{}{}
}
}
parent := Dir(curPath)
if parent == curPath {
break
}
curPath = parent
}
return n
}
Expand Down
1 change: 1 addition & 0 deletions private/pkg/normalpath/normalpath_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ func TestMapAllEqualOrContainingPaths(t *testing.T) {
testMapAllEqualOrContainingPaths(t, []string{"b"}, "b/a/c", "b")
testMapAllEqualOrContainingPaths(t, []string{"b", "."}, "b/b/c", "b", ".")
testMapAllEqualOrContainingPaths(t, []string{"b", "b/b", "."}, "b/b/c", "b", "b/b", ".")
testMapAllEqualOrContainingPaths(t, []string{"A", "a", "a/B"}, "a/b/c", "A", "a", "a/B", "b")
}

func testMapAllEqualOrContainingPaths(t *testing.T, expected []string, path string, keys ...string) {
Expand Down
Loading