From 320183fa54df3283ffc43a89d5efa5b4bc37323a Mon Sep 17 00:00:00 2001 From: d3x0r Date: Wed, 21 Dec 2016 12:17:01 -0800 Subject: [PATCH] Set default options more robustly --- lib/wsp/Peer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/wsp/Peer.js b/lib/wsp/Peer.js index e8a0b3ae..42527e04 100644 --- a/lib/wsp/Peer.js +++ b/lib/wsp/Peer.js @@ -83,7 +83,8 @@ function Peer (url, options) { this.setMaxListeners(Infinity); this.options = options || {}; - this.options.wsc = options.wsc || { protocols: null }; + if( !('wsc" in this.options ) ) this.options.wsc = options.wsc || { protocols: null }; + else if( !("protocols" in this.options.wsc) ) this.options.wsc.protocols = null; // Messages sent before the socket is ready. this.deferredMsgs = [];