diff --git a/qunitjs/javascript/test-URI.js b/qunitjs/javascript/test-URI.js index 3db9d2f32..bba2633ab 100644 --- a/qunitjs/javascript/test-URI.js +++ b/qunitjs/javascript/test-URI.js @@ -11,6 +11,8 @@ test('JsSIP.URI', function() { deepEqual(uri.headers, {}); strictEqual(uri.toString(), 'sip:alice@jssip.net:6060'); strictEqual(uri.toAor(), 'sip:alice@jssip.net'); + strictEqual(uri.toAor(false), 'sip:alice@jssip.net'); + strictEqual(uri.toAor(true), 'sip:alice@jssip.net:6060'); uri.scheme = 'SIPS'; strictEqual(uri.scheme, 'sips'); diff --git a/src/URI.js b/src/URI.js index 814cca0cd..578880e30 100644 --- a/src/URI.js +++ b/src/URI.js @@ -163,7 +163,7 @@ JsSIP.URI.prototype = { return uri; }, - toAor: function(){ + toAor: function(show_port){ var aor; aor = this.scheme + ':'; @@ -171,6 +171,9 @@ JsSIP.URI.prototype = { aor += JsSIP.Utils.escapeUser(this.user) + '@'; } aor += this.host; + if (show_port && (this.port || this.port === 0)) { + aor += ':' + this.port; + } return aor; }