all: use strings.EqualFold for string comparison #24890 (#1134)

This commit is contained in:
JukLee0ira 2025-06-23 16:00:32 +08:00 committed by GitHub
parent e966001937
commit a74b87307c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 5 deletions

View file

@ -143,7 +143,7 @@ func (p *terminalPrompter) PromptPassword(prompt string) (passwd string, err err
// choice to be made, returning that choice. // choice to be made, returning that choice.
func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) { func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) {
input, err := p.Prompt(prompt + " [y/N] ") input, err := p.Prompt(prompt + " [y/N] ")
if len(input) > 0 && strings.ToUpper(input[:1]) == "Y" { if len(input) > 0 && strings.EqualFold(input[:1], "y") {
return true, nil return true, nil
} }
return false, err return false, err

View file

@ -237,12 +237,12 @@ func (c *Compiler) pushBin(v interface{}) {
// isPush returns whether the string op is either any of // isPush returns whether the string op is either any of
// push(N). // push(N).
func isPush(op string) bool { func isPush(op string) bool {
return op == "push" return strings.EqualFold(op, "PUSH")
} }
// isJump returns whether the string op is jump(i) // isJump returns whether the string op is jump(i)
func isJump(op string) bool { func isJump(op string) bool {
return op == "jumpi" || op == "jump" return strings.EqualFold(op, "JUMPI") || strings.EqualFold(op, "JUMP")
} }
// toBinary converts text to a vm.OpCode // toBinary converts text to a vm.OpCode

View file

@ -375,7 +375,7 @@ func (h *httpServer) wsAllowed() bool {
// isWebsocket checks the header of an http request for a websocket upgrade request. // isWebsocket checks the header of an http request for a websocket upgrade request.
func isWebsocket(r *http.Request) bool { func isWebsocket(r *http.Request) bool {
return strings.ToLower(r.Header.Get("Upgrade")) == "websocket" && return strings.EqualFold(r.Header.Get("Upgrade"), "websocket") &&
strings.Contains(strings.ToLower(r.Header.Get("Connection")), "upgrade") strings.Contains(strings.ToLower(r.Header.Get("Connection")), "upgrade")
} }

View file

@ -230,7 +230,7 @@ func baseRpcRequest(t *testing.T, url, bodyStr string, extraHeaders ...string) *
} }
for i := 0; i < len(extraHeaders); i += 2 { for i := 0; i < len(extraHeaders); i += 2 {
key, value := extraHeaders[i], extraHeaders[i+1] key, value := extraHeaders[i], extraHeaders[i+1]
if strings.ToLower(key) == "host" { if strings.EqualFold(key, "host") {
req.Host = value req.Host = value
} else { } else {
req.Header.Set(key, value) req.Header.Set(key, value)