Skip to content

Commit

Permalink
ignore empty fields properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemcdonald committed Jun 2, 2014
1 parent 44c4838 commit bb5945d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ app.post('/', function(req, res) {
});

function addField(object, field, data) {
if(data || data == 0) {
// a string with length > 0
// or a number that is 0 or greater
if((typeof data == 'string' && data.length > 0) ||
(typeof data == 'number' && data >= 0)) {
object[field] = data;
}
}
Expand Down

0 comments on commit bb5945d

Please sign in to comment.