Avoid strings.ReplaceAll() that was introduced too recently
This commit is contained in:
parent
ed0dbc2b55
commit
63e6dbdac7
|
@ -134,6 +134,15 @@ func StringQuote(str string) string {
|
|||
return str[1 : len(str)-1]
|
||||
}
|
||||
|
||||
func StringStripSpaces(str string) string {
|
||||
return strings.Map(func(r rune) rune {
|
||||
if unicode.IsSpace(r) {
|
||||
return -1
|
||||
}
|
||||
return r
|
||||
}, str)
|
||||
}
|
||||
|
||||
func ExtractPort(str string, defaultPort int) int {
|
||||
port := defaultPort
|
||||
if idx := strings.LastIndex(str, ":"); idx >= 0 && idx < len(str)-1 {
|
||||
|
|
|
@ -154,7 +154,7 @@ func InitPluginsGlobals(pluginsGlobals *PluginsGlobals, proxy *Proxy) error {
|
|||
|
||||
// blockedQueryResponse can be 'refused', 'hinfo' or IP responses 'a:IPv4,aaaa:IPv6
|
||||
func parseBlockedQueryResponse(blockedResponse string, pluginsGlobals *PluginsGlobals) {
|
||||
blockedResponse = strings.ReplaceAll(strings.ToLower(blockedResponse), " ", "")
|
||||
blockedResponse = StringStripSpaces(strings.ToLower(blockedResponse))
|
||||
|
||||
if strings.HasPrefix(blockedResponse, "a:") {
|
||||
blockedIPStrings := strings.Split(blockedResponse, ",")
|
||||
|
|
Loading…
Reference in New Issue