mirror of https://github.com/minio/minio.git
Simplify cast of string to rune slice in wildcard matching (#9577)
This commit is contained in:
parent
ee9077db7d
commit
a9558ae248
|
@ -26,16 +26,8 @@ func MatchSimple(pattern, name string) bool {
|
||||||
if pattern == "*" {
|
if pattern == "*" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
rname := make([]rune, 0, len(name))
|
// Does only wildcard '*' match.
|
||||||
rpattern := make([]rune, 0, len(pattern))
|
return deepMatchRune([]rune(name), []rune(pattern), true)
|
||||||
for _, r := range name {
|
|
||||||
rname = append(rname, r)
|
|
||||||
}
|
|
||||||
for _, r := range pattern {
|
|
||||||
rpattern = append(rpattern, r)
|
|
||||||
}
|
|
||||||
simple := true // Does only wildcard '*' match.
|
|
||||||
return deepMatchRune(rname, rpattern, simple)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match - finds whether the text matches/satisfies the pattern string.
|
// Match - finds whether the text matches/satisfies the pattern string.
|
||||||
|
@ -49,16 +41,8 @@ func Match(pattern, name string) (matched bool) {
|
||||||
if pattern == "*" {
|
if pattern == "*" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
rname := make([]rune, 0, len(name))
|
// Does extended wildcard '*' and '?' match.
|
||||||
rpattern := make([]rune, 0, len(pattern))
|
return deepMatchRune([]rune(name), []rune(pattern), false)
|
||||||
for _, r := range name {
|
|
||||||
rname = append(rname, r)
|
|
||||||
}
|
|
||||||
for _, r := range pattern {
|
|
||||||
rpattern = append(rpattern, r)
|
|
||||||
}
|
|
||||||
simple := false // Does extended wildcard '*' and '?' match.
|
|
||||||
return deepMatchRune(rname, rpattern, simple)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func deepMatchRune(str, pattern []rune, simple bool) bool {
|
func deepMatchRune(str, pattern []rune, simple bool) bool {
|
||||||
|
|
Loading…
Reference in New Issue