Skip to content

Commit

Permalink
Fix potential bug in options handling
Browse files Browse the repository at this point in the history
Problem: If an option contained 0 or another false-ish value, it would
go ignored. So far this was no problem because no such values are to
be expected, but this might cause bugs if more options are introduced.

Solution: Check on the actual presence of the option key in the options
object regardless of value.

See discussion: https://twitter.com/felixge/status/55615426058649600
  • Loading branch information
felixge committed Apr 6, 2011
1 parent 737ca08 commit 05984be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/growing_file.js
Expand Up @@ -30,8 +30,10 @@ GrowingFile.open = function(path, options) {
options = options || {};
['timeout', 'interval']
.forEach(function(option) {
var property = '_' + option;
file[property] = options[option] || file[property];
if (option in options) {
var property = '_' + option;
file[property] = options[option];
}
});

file._path = path;
Expand Down

0 comments on commit 05984be

Please sign in to comment.