summaryrefslogtreecommitdiff
path: root/ext/websocket/02_websocketstream.js
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2023-04-03 02:41:41 +0900
committerGitHub <noreply@github.com>2023-04-02 19:41:41 +0200
commit03edd48edd004cec091541e6b71095cfbc4b4c87 (patch)
tree72aed1dae803334b73479ffebc7ca8c83d10addf /ext/websocket/02_websocketstream.js
parentad8d0c90d1887beb8a5f2c6d30f9dc71cc63e4fe (diff)
chore: Turn back on dlintPreferPrimordials (#17715)
Closes #17709
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.",