summaryrefslogtreecommitdiff
path: root/ext/websocket/02_websocketstream.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/websocket/02_websocketstream.js')
-rw-r--r--ext/websocket/02_websocketstream.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/ext/websocket/02_websocketstream.js b/ext/websocket/02_websocketstream.js
index 6e487f0b7..46bd7deae 100644
--- a/ext/websocket/02_websocketstream.js
+++ b/ext/websocket/02_websocketstream.js
@@ -22,10 +22,12 @@ const {
PromisePrototypeCatch,
PromisePrototypeThen,
Set,
+ SetPrototypeGetSize,
StringPrototypeEndsWith,
StringPrototypeToLowerCase,
Symbol,
SymbolFor,
+ TypedArrayPrototypeGetByteLength,
TypeError,
Uint8ArrayPrototype,
} = primordials;
@@ -115,12 +117,14 @@ class WebSocketStream {
if (
options.protocols.length !==
- new Set(
- ArrayPrototypeMap(
- options.protocols,
- (p) => StringPrototypeToLowerCase(p),
+ SetPrototypeGetSize(
+ new Set(
+ ArrayPrototypeMap(
+ options.protocols,
+ (p) => StringPrototypeToLowerCase(p),
+ ),
),
- ).size
+ )
) {
throw new DOMException(
"Can't supply multiple times the same protocol.",
@@ -394,7 +398,8 @@ class WebSocketStream {
const encoder = new TextEncoder();
if (
- closeInfo.reason && encoder.encode(closeInfo.reason).byteLength > 123
+ closeInfo.reason &&
+ TypedArrayPrototypeGetByteLength(encoder.encode(closeInfo.reason)) > 123
) {
throw new DOMException(
"The close reason may not be longer than 123 bytes.",