Skip to content

Commit

Permalink
Uses strings.Equalfold (#1790)
Browse files Browse the repository at this point in the history
Changes case insensitive string comparisons to string.EqualFold which performs better than strings.Lower(str) == str comparison
  • Loading branch information
rkilingr committed Feb 26, 2021
1 parent 6a666ac commit 45870c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (c *context) IsTLS() bool {

func (c *context) IsWebSocket() bool {
upgrade := c.request.Header.Get(HeaderUpgrade)
return strings.ToLower(upgrade) == "websocket"
return strings.EqualFold(upgrade, "websocket")
}

func (c *context) Scheme() string {
Expand Down
2 changes: 1 addition & 1 deletion middleware/basic_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
auth := c.Request().Header.Get(echo.HeaderAuthorization)
l := len(basic)

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

0 comments on commit 45870c7

Please sign in to comment.