Skip to content
Permalink
Browse files

Improvements and some bug fixes in URI and NameAddrHeader classes.

  • Loading branch information
ibc committed Feb 13, 2013
1 parent fda507a commit 826ce12b1baab4b17959e68828c0ecf195b6023f
Showing with 14 additions and 9 deletions.
  1. +2 −2 src/NameAddrHeader.js
  2. +12 −7 src/URI.js
@@ -36,7 +36,7 @@ JsSIP.NameAddrHeader = function(uri, display_name, parameters) {
JsSIP.NameAddrHeader.prototype = {
setParam: function(key, value) {
if (key) {
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString().toLowerCase();
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null) ? null : value.toString().toLowerCase();
}
},

@@ -76,7 +76,7 @@ JsSIP.NameAddrHeader.prototype = {
toString: function() {
var body, parameter;

body = (this.display_name) ? '"' + this.display_name + '" ' : '';
body = (this.display_name || this.display_name === 0) ? '"' + this.display_name + '" ' : '';
body += '<' + this.uri.toString() + '>';

for (parameter in this.parameters) {
@@ -18,9 +18,8 @@ JsSIP.URI = function(scheme, user, host, port, parameters, headers) {
throw new TypeError('missing or invalid "host" parameter');
}

scheme = scheme || JsSIP.C.SIP;

// Initialize parameters
scheme = scheme || JsSIP.C.SIP;
this.parameters = {};
this.headers = {};

@@ -56,7 +55,7 @@ JsSIP.URI = function(scheme, user, host, port, parameters, headers) {
port: {
get: function(){ return port; },
set: function(value){
port = parseInt(value,10);
port = value === 0 ? value : (parseInt(value,10) || null);
}
}
});
@@ -106,7 +105,7 @@ JsSIP.URI.prototype = {

hasHeader: function(name) {
if(name) {
return (this.headers.hasOwnProperty(name.toLowerCase()) && true) || false;
return (this.headers.hasOwnProperty(JsSIP.Utils.headerize(name)) && true) || false;
}
},

@@ -139,9 +138,13 @@ JsSIP.URI.prototype = {
headers = [];

uri = this.scheme + ':';
uri += this.user ? JsSIP.Utils.escapeUser(this.user) + '@' : '';
if (this.user) {
uri += JsSIP.Utils.escapeUser(this.user) + '@';
}
uri += this.host;
uri += this.port ? ':' + this.port : '';
if (this.port || this.port === 0) {
uri += ':' + this.port;
}

for (parameter in this.parameters) {
uri += ';'+ parameter;
@@ -164,7 +167,9 @@ JsSIP.URI.prototype = {
var aor;

aor = this.scheme + ':';
aor += this.user ? JsSIP.Utils.escapeUser(this.user) + '@' : '';
if (this.user) {
aor += JsSIP.Utils.escapeUser(this.user) + '@';
}
aor += this.host;

return aor;

0 comments on commit 826ce12

Please sign in to comment.
You can’t perform that action at this time.