summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-09-29 16:26:02 +0200
committerPierre Ossman <ossman@cendio.se>2017-09-29 16:26:02 +0200
commit8290d3f271c0a1150772dbe10b5854bc9c1fca73 (patch)
tree406ede58aa217b3e9d710200c02030545c280581
parent0242c032807096a0e823418e39dec646ec025414 (diff)
parent1a50f6809f77dc6baf42ac8003f1efa526df1c57 (diff)
downloadnovnc-8290d3f271c0a1150772dbe10b5854bc9c1fca73.tar.gz
Merge branch 'optional-port' of https://github.com/bkylerussell/noVNC
-rw-r--r--core/rfb.js11
-rw-r--r--tests/test.rfb.js16
2 files changed, 15 insertions, 12 deletions
diff --git a/core/rfb.js b/core/rfb.js
index 3dc7cbc..50f4083 100644
--- a/core/rfb.js
+++ b/core/rfb.js
@@ -270,9 +270,9 @@ RFB.prototype = {
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 = '';
@@ -393,7 +393,12 @@ RFB.prototype = {
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;
+
Log.Info("connecting to " + uri);
try {
diff --git a/tests/test.rfb.js b/tests/test.rfb.js
index fb67177..fe0e92d 100644
--- a/tests/test.rfb.js
+++ b/tests/test.rfb.js
@@ -85,15 +85,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 () {
@@ -507,6 +498,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 () {