Skip to content

Commit 0c0754b

Browse files
authored
[fix] Use the byte length of the data (#2004)
Ensure that the correct length is used when framing the data.
1 parent 6ebfeb8 commit 0c0754b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/sender.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ class Sender {
103103

104104
let payloadLength = dataLength;
105105

106-
if (data.length >= 65536) {
106+
if (dataLength >= 65536) {
107107
offset += 8;
108108
payloadLength = 127;
109-
} else if (data.length > 125) {
109+
} else if (dataLength > 125) {
110110
offset += 2;
111111
payloadLength = 126;
112112
}
@@ -136,11 +136,11 @@ class Sender {
136136
if (skipMasking) return [target, data];
137137

138138
if (merge) {
139-
applyMask(data, mask, target, offset, data.length);
139+
applyMask(data, mask, target, offset, dataLength);
140140
return [target];
141141
}
142142

143-
applyMask(data, mask, data, 0, data.length);
143+
applyMask(data, mask, data, 0, dataLength);
144144
return [target, data];
145145
}
146146

0 commit comments

Comments
 (0)