Skip to content

Commit e644d45

Browse files
authored
all: use strings.EqualFold for string comparison (ethereum#24890)
1 parent e0a9752 commit e644d45

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

console/prompt/prompter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (p *terminalPrompter) PromptPassword(prompt string) (passwd string, err err
143143
// choice to be made, returning that choice.
144144
func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) {
145145
input, err := p.Prompt(prompt + " [y/n] ")
146-
if len(input) > 0 && strings.ToUpper(input[:1]) == "Y" {
146+
if len(input) > 0 && strings.EqualFold(input[:1], "y") {
147147
return true, nil
148148
}
149149
return false, err

core/asm/compiler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ func (c *Compiler) pushBin(v interface{}) {
243243
// isPush returns whether the string op is either any of
244244
// push(N).
245245
func isPush(op string) bool {
246-
return strings.ToUpper(op) == "PUSH"
246+
return strings.EqualFold(op, "PUSH")
247247
}
248248

249249
// isJump returns whether the string op is jump(i)
250250
func isJump(op string) bool {
251-
return strings.ToUpper(op) == "JUMPI" || strings.ToUpper(op) == "JUMP"
251+
return strings.EqualFold(op, "JUMPI") || strings.EqualFold(op, "JUMP")
252252
}
253253

254254
// toBinary converts text to a vm.OpCode

node/rpcstack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func (h *httpServer) wsAllowed() bool {
357357

358358
// isWebsocket checks the header of an http request for a websocket upgrade request.
359359
func isWebsocket(r *http.Request) bool {
360-
return strings.ToLower(r.Header.Get("Upgrade")) == "websocket" &&
360+
return strings.EqualFold(r.Header.Get("Upgrade"), "websocket") &&
361361
strings.Contains(strings.ToLower(r.Header.Get("Connection")), "upgrade")
362362
}
363363

node/rpcstack_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func rpcRequest(t *testing.T, url string, extraHeaders ...string) *http.Response
283283
}
284284
for i := 0; i < len(extraHeaders); i += 2 {
285285
key, value := extraHeaders[i], extraHeaders[i+1]
286-
if strings.ToLower(key) == "host" {
286+
if strings.EqualFold(key, "host") {
287287
req.Host = value
288288
} else {
289289
req.Header.Set(key, value)

0 commit comments

Comments
 (0)