Skip to content

Commit

Permalink
Allow passing an empty array as a configuration parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Nov 28, 2013
1 parent d8e0a11 commit 0a5bccd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ UA.prototype.loadConfig = function(configuration) {
if(configuration.hasOwnProperty(parameter)) {
value = configuration[parameter];

// If the parameter value is null, empty string or undefined then apply its default value.
if(value === null || value === "" || value === undefined) { continue; }
// If the parameter value is null, empty string, undefined or empty array then apply its default value.
if(value === null || value === "" || value === undefined || (value instanceof Array && value.length === 0)) { continue; }
// If it's a number with NaN value then also apply its default value.
// NOTE: JS does not allow "value === NaN", the following does the work:
else if(typeof(value) === 'number' && window.isNaN(value)) { continue; }
Expand Down

3 comments on commit 0a5bccd

@mEkblom
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly setting a value of empty string or empty array should not be filtered away, this will break some implementations. There are occasions when an empty string or array are useful, and this is the desired value to use (in our case to send an empty list of STUN servers).

Please count only undefined and null as a request for default value! Thanks.

@ibc
Copy link
Member

@ibc ibc commented on 0a5bccd Mar 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.
Even more: I think that the default value for "stun_servers" should be an empty array (so no STUN servers).

@ibc
Copy link
Member

@ibc ibc commented on 0a5bccd Mar 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's address this in #206.

Please sign in to comment.