Skip to content
Permalink
Browse files

Enhance URI and NameAddrHeader

- 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 da58bff09adb4648c3b5c09cd474dea1605d16cb
Showing with 11 additions and 3 deletions.
  1. +4 −1 src/NameAddrHeader.js
  2. +7 −2 src/URI.js
@@ -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();
}
},

@@ -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;
}
},

@@ -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();
}
},

@@ -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;
}
},

@@ -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() {

0 comments on commit da58bff

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