Skip to content

Commit

Permalink
Fix WebSocket constructor chocking on empty protocol string; close ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
phoboslab committed Sep 4, 2022
1 parent c56be4e commit 3afb0e5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ WSSource.prototype.start = function() {
this.progress = 0;
this.established = false;

this.socket = new WebSocket(this.url, this.options.protocols || null);
if (this.options.protocols) {
this.socket = new WebSocket(this.url, this.options.protocols);
}
else {
this.socket = new WebSocket(this.url);
}
this.socket.binaryType = 'arraybuffer';
this.socket.onmessage = this.onMessage.bind(this);
this.socket.onopen = this.onOpen.bind(this);
Expand Down

0 comments on commit 3afb0e5

Please sign in to comment.