Skip to content

Commit 7211bde

Browse files
committed
JsSIP.URI.toAor() now accepts 'show_port' param. When true the port is added to the resulting string (if there is port).
1 parent eb1f26f commit 7211bde

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

qunitjs/javascript/test-URI.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ test('JsSIP.URI', function() {
1111
deepEqual(uri.headers, {});
1212
strictEqual(uri.toString(), 'sip:alice@jssip.net:6060');
1313
strictEqual(uri.toAor(), 'sip:alice@jssip.net');
14+
strictEqual(uri.toAor(false), 'sip:alice@jssip.net');
15+
strictEqual(uri.toAor(true), 'sip:alice@jssip.net:6060');
1416

1517
uri.scheme = 'SIPS';
1618
strictEqual(uri.scheme, 'sips');

src/URI.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,17 @@ JsSIP.URI.prototype = {
163163

164164
return uri;
165165
},
166-
toAor: function(){
166+
toAor: function(show_port){
167167
var aor;
168168

169169
aor = this.scheme + ':';
170170
if (this.user) {
171171
aor += JsSIP.Utils.escapeUser(this.user) + '@';
172172
}
173173
aor += this.host;
174+
if (show_port && (this.port || this.port === 0)) {
175+
aor += ':' + this.port;
176+
}
174177

175178
return aor;
176179
}

0 commit comments

Comments
 (0)