Skip to content

Commit

Permalink
Enhance URI and NameAddrHeader
Browse files Browse the repository at this point in the history
- Return the deleted header/paramter in deleteParam()/deleteHeader()
- Lowercase parameter value on setParam()
  • Loading branch information
jmillan committed Feb 12, 2013
1 parent df6dd98 commit da58bff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/NameAddrHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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();
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString().toLowerCase();
}
},

Expand All @@ -54,9 +54,12 @@ JsSIP.NameAddrHeader.prototype = {
},

deleteParam: function(parameter) {
var value;
parameter = parameter.toLowerCase();
if (this.parameters.hasOwnProperty(parameter)) {
value = this.parameters[parameter];
delete this.parameters[parameter];
return value;
}
},

Expand Down
9 changes: 7 additions & 2 deletions src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ JsSIP.URI = function(scheme, user, host, port, parameters, headers) {
JsSIP.URI.prototype = {
setParam: function(key, value) {
if(key) {
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString();
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString().toLowerCase();
}
},

Expand All @@ -80,9 +80,12 @@ JsSIP.URI.prototype = {
},

deleteParam: function(parameter) {
var value;
parameter = parameter.toLowerCase();
if (this.parameters.hasOwnProperty(parameter)) {
value = this.parameters[parameter];
delete this.parameters[parameter];
return value;
}
},

Expand All @@ -107,15 +110,17 @@ JsSIP.URI.prototype = {
},

deleteHeader: function(header) {
var value;
header = JsSIP.Utils.headerize(header);
if(this.headers.hasOwnProperty(header)) {
value = this.headers[header];
delete this.headers[header];
return value;
}
},

clearHeaders: function() {
this.headers = {};
return this.headers;
},

clone: function() {
Expand Down

0 comments on commit da58bff

Please sign in to comment.