Skip to content

Commit

Permalink
fix: set "WebSocket.protocol" to an empty string by default (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman authored Jun 6, 2024
1 parent 8ba00ca commit 87ae1e3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/interceptors/WebSocket/WebSocketOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export class WebSocketOverride extends EventTarget implements WebSocket {
Reflect.set(this, 'readyState', this.CONNECTING)
queueMicrotask(() => {
Reflect.set(this, 'readyState', this.OPEN)
this.protocol = protocols ? protocols[0] : 'ws'
this.protocol =
typeof protocols === 'string'
? protocols
: Array.isArray(protocols) && protocols.length > 0
? protocols[0]
: ''

this.dispatchEvent(bindEvent(this, new Event('open')))
})
Expand Down

0 comments on commit 87ae1e3

Please sign in to comment.