Skip to content
Merged
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
18 changes: 9 additions & 9 deletions pkg/util/wildcard/wildcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ func Match(pattern, name string) (matched bool) {
if pattern == "*" {
return true
}
// Does extended wildcard '*' and '?' match.
return deepMatchRune([]rune(name), []rune(pattern), false)
// Does extended wildcard '*' and '?' match?
return deepMatchRune(name, pattern, false)
}

func deepMatchRune(str, pattern []rune, simple bool) bool {
func deepMatchRune(s, pattern string, simple bool) bool {
for len(pattern) > 0 {
switch pattern[0] {
default:
if len(str) == 0 || str[0] != pattern[0] {
if len(s) == 0 || s[0] != pattern[0] {
return false
}
case '?':
if len(str) == 0 && !simple {
if len(s) == 0 && !simple {
return false
}
case '*':
return deepMatchRune(str, pattern[1:], simple) ||
(len(str) > 0 && deepMatchRune(str[1:], pattern, simple))
return deepMatchRune(s, pattern[1:], simple) ||
(len(s) > 0 && deepMatchRune(s[1:], pattern, simple))
}
str = str[1:]
s = s[1:]
pattern = pattern[1:]
}
return len(str) == 0 && len(pattern) == 0
return len(s) == 0 && len(pattern) == 0
}