Skip to content

Commit da58bff

Browse files
committed
Enhance URI and NameAddrHeader
- Return the deleted header/paramter in deleteParam()/deleteHeader() - Lowercase parameter value on setParam()
1 parent df6dd98 commit da58bff

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/NameAddrHeader.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ JsSIP.NameAddrHeader = function(uri, display_name, parameters) {
3737
JsSIP.NameAddrHeader.prototype = {
3838
setParam: function(key, value) {
3939
if (key) {
40-
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString();
40+
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString().toLowerCase();
4141
}
4242
},
4343

@@ -54,9 +54,12 @@ JsSIP.NameAddrHeader.prototype = {
5454
},
5555

5656
deleteParam: function(parameter) {
57+
var value;
5758
parameter = parameter.toLowerCase();
5859
if (this.parameters.hasOwnProperty(parameter)) {
60+
value = this.parameters[parameter];
5961
delete this.parameters[parameter];
62+
return value;
6063
}
6164
},
6265

src/URI.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ JsSIP.URI = function(scheme, user, host, port, parameters, headers) {
6363
JsSIP.URI.prototype = {
6464
setParam: function(key, value) {
6565
if(key) {
66-
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString();
66+
this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null)? null : value.toString().toLowerCase();
6767
}
6868
},
6969

@@ -80,9 +80,12 @@ JsSIP.URI.prototype = {
8080
},
8181

8282
deleteParam: function(parameter) {
83+
var value;
8384
parameter = parameter.toLowerCase();
8485
if (this.parameters.hasOwnProperty(parameter)) {
86+
value = this.parameters[parameter];
8587
delete this.parameters[parameter];
88+
return value;
8689
}
8790
},
8891

@@ -107,15 +110,17 @@ JsSIP.URI.prototype = {
107110
},
108111

109112
deleteHeader: function(header) {
113+
var value;
110114
header = JsSIP.Utils.headerize(header);
111115
if(this.headers.hasOwnProperty(header)) {
116+
value = this.headers[header];
112117
delete this.headers[header];
118+
return value;
113119
}
114120
},
115121

116122
clearHeaders: function() {
117123
this.headers = {};
118-
return this.headers;
119124
},
120125

121126
clone: function() {

0 commit comments

Comments
 (0)