diff --git a/core/rfb.js b/core/rfb.js index bc1fc613..334cd27e 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -273,9 +273,9 @@ this._rfb_password = (password !== undefined) ? password : ""; this._rfb_path = (path !== undefined) ? path : ""; - if (!this._rfb_host || !this._rfb_port) { + if (!this._rfb_host) { return this._fail( - _("Must set host and port")); + _("Must set host")); } this._rfb_init_state = ''; @@ -379,7 +379,12 @@ uri = this._encrypt ? 'wss' : 'ws'; } - uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path; + uri += '://' + this._rfb_host; + if(this._rfb_port) { + uri += ':' + this._rfb_port; + } + uri += '/' + this._rfb_path; + Util.Info("connecting to " + uri); try { diff --git a/tests/test.rfb.js b/tests/test.rfb.js index ae51bffc..4bd85de0 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -81,15 +81,6 @@ describe('Remote Frame Buffer Protocol Client', function() { expect(client._updateConnectionState).to.not.have.been.called; expect(client._rfb_connection_state).to.equal(''); }); - - it('should not try to connect if we are missing a port', function () { - client._fail = sinon.spy(); - client._rfb_connection_state = ''; - client.connect('abc'); - expect(client._fail).to.have.been.calledOnce; - expect(client._updateConnectionState).to.not.have.been.called; - expect(client._rfb_connection_state).to.equal(''); - }); }); describe('#disconnect', function () { @@ -487,6 +478,13 @@ describe('Remote Frame Buffer Protocol Client', function() { client._updateConnectionState('connecting'); expect(client._sock.open).to.have.been.calledWith('ws://HOST:8675/PATH'); }); + + it('should not include a port in the uri if not specified in connect', function () { + sinon.spy(client._sock, 'open'); + client.set_encrypt(true); + client.connect('HOST', undefined) + expect(client._sock.open).to.have.been.calledWith('wss://HOST/'); + }); }); describe('disconnecting', function () {