diff --git a/lib/transports/websocket/default.js b/lib/transports/websocket/default.js index 2e861a74..091fdd44 100644 --- a/lib/transports/websocket/default.js +++ b/lib/transports/websocket/default.js @@ -1,4 +1,3 @@ - /*! * socket.io-node * Copyright(c) 2011 LearnBoost @@ -89,11 +88,14 @@ WebSocket.prototype.onSocketConnect = function () { } var origin = this.req.headers['origin'] - , location = ((this.manager.settings['match origin protocol'] ? - origin.match(/^https/) : this.socket.encrypted) ? - 'wss' : 'ws') - + '://' + this.req.headers.host + this.req.url - , waitingForNonce = false; + , waitingForNonce = false; + if(this.manager.settings['match origin protocol']){ + location = (origin.indexOf('https')>-1 ? 'wss' : 'ws') + '://' + this.req.headers.host + this.req.url; + }else if(this.socket.encrypted){ + location = 'wss://' + this.req.headers.host + this.req.url; + }else{ + location = 'ws://' + this.req.headers.host + this.req.url; + } if (this.req.headers['sec-websocket-key1']) { // If we don't have the nonce yet, wait for it (HAProxy compatibility).