Fix sub protocol handling when no protocol is specified
Some browsers are being difficult and won't let us pass on undefined values for the protocols argument.
This commit is contained in:
parent
5e19bc3f96
commit
0506b3431f
|
@ -218,7 +218,14 @@
|
|||
var ws_schema = uri.match(/^([a-z]+):\/\//)[1];
|
||||
this.init();
|
||||
|
||||
this._websocket = new WebSocket(uri, protocols);
|
||||
// IE, Edge and Firefox misbehave when protocols is
|
||||
// undefined, converting it to a string rather than
|
||||
// treating it as if it wasn't specified
|
||||
if (protocols) {
|
||||
this._websocket = new WebSocket(uri, protocols);
|
||||
} else {
|
||||
this._websocket = new WebSocket(uri);
|
||||
}
|
||||
this._websocket.binaryType = 'arraybuffer';
|
||||
|
||||
this._websocket.onmessage = this._recv_message.bind(this);
|
||||
|
|
Loading…
Reference in New Issue