Skip to content

Commit

Permalink
[fix] Use the byte length of the data (#2004)
Browse files Browse the repository at this point in the history
Ensure that the correct length is used when framing the data.
  • Loading branch information
ronag committed Jan 14, 2022
1 parent 6ebfeb8 commit 0c0754b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/sender.js
Expand Up @@ -103,10 +103,10 @@ class Sender {

let payloadLength = dataLength;

if (data.length >= 65536) {
if (dataLength >= 65536) {
offset += 8;
payloadLength = 127;
} else if (data.length > 125) {
} else if (dataLength > 125) {
offset += 2;
payloadLength = 126;
}
Expand Down Expand Up @@ -136,11 +136,11 @@ class Sender {
if (skipMasking) return [target, data];

if (merge) {
applyMask(data, mask, target, offset, data.length);
applyMask(data, mask, target, offset, dataLength);
return [target];
}

applyMask(data, mask, data, 0, data.length);
applyMask(data, mask, data, 0, dataLength);
return [target, data];
}

Expand Down

0 comments on commit 0c0754b

Please sign in to comment.