Skip to content

Commit 45870c7

Browse files
authored
Uses strings.Equalfold (#1790)
Changes case insensitive string comparisons to string.EqualFold which performs better than strings.Lower(str) == str comparison
1 parent 6a666ac commit 45870c7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (c *context) IsTLS() bool {
246246

247247
func (c *context) IsWebSocket() bool {
248248
upgrade := c.request.Header.Get(HeaderUpgrade)
249-
return strings.ToLower(upgrade) == "websocket"
249+
return strings.EqualFold(upgrade, "websocket")
250250
}
251251

252252
func (c *context) Scheme() string {

middleware/basic_auth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
7373
auth := c.Request().Header.Get(echo.HeaderAuthorization)
7474
l := len(basic)
7575

76-
if len(auth) > l+1 && strings.ToLower(auth[:l]) == basic {
76+
if len(auth) > l+1 && strings.EqualFold(auth[:l], basic) {
7777
b, err := base64.StdEncoding.DecodeString(auth[l+1:])
7878
if err != nil {
7979
return err

0 commit comments

Comments
 (0)