Skip to content

Commit e582c1f

Browse files
authored
use base64.StdEncoding.AppendEncode in encodeAcceptKey (#481)
1 parent 3757487 commit e582c1f

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

internal/websocket/util.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/base64"
1111
"io"
1212
"net/http"
13-
"slices"
1413
"strings"
1514
"sync"
1615
"unicode/utf8"
@@ -44,11 +43,7 @@ func encodeAcceptKey(challengeKey string, p []byte) []byte {
4443
*bufPtr = (*bufPtr)[:0]
4544
sum := h.Sum(*bufPtr)
4645

47-
// replace with base64.AppendEncode when we can depend on Go 1.22.
48-
n := base64.StdEncoding.EncodedLen(len(sum))
49-
p = slices.Grow(p, n)
50-
base64.StdEncoding.Encode(p[len(p):][:n], sum)
51-
return p[:len(p)+n]
46+
return base64.StdEncoding.AppendEncode(p, sum)
5247
}
5348

5449
func generateChallengeKey() (string, error) {

0 commit comments

Comments
 (0)