2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-09-05 17:10:35 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package redis
|
|
|
|
|
|
|
|
func escapeMatch(match []byte) []byte {
|
|
|
|
start := 0
|
|
|
|
escaped := []byte{}
|
|
|
|
for i, b := range match {
|
|
|
|
switch b {
|
|
|
|
case '?', '*', '[', ']', '\\':
|
|
|
|
escaped = append(escaped, match[start:i]...)
|
|
|
|
escaped = append(escaped, '\\', b)
|
|
|
|
start = i + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if start == 0 {
|
|
|
|
return match
|
|
|
|
}
|
|
|
|
|
|
|
|
return append(escaped, match[start:]...)
|
|
|
|
}
|