diff --git a/lib/reparse.js b/lib/reparse.js index 7729e99..3751dad 100644 --- a/lib/reparse.js +++ b/lib/reparse.js @@ -111,10 +111,10 @@ return this.fail(); } this.input = this.input.substr(((probe[1] != null) && putback ? probe[1].length : probe[0].length)); - if (probe[1] != null) { - return probe[1]; - } else { + if (probe[1] === undefined) { return probe[0]; + } else { + return probe[1]; } }; diff --git a/src/reparse.coffee b/src/reparse.coffee index 0943f3d..408e7e4 100644 --- a/src/reparse.coffee +++ b/src/reparse.coffee @@ -79,7 +79,7 @@ exports.ReParse = class ReParse probe = @input.match pattern return @fail() unless probe @input = @input.substr (if probe[1]? and putback then probe[1].length else probe[0].length) - if probe[1]? then probe[1] else probe[0] + if probe[1] is `undefined` then probe[0] else probe[1] # Attempts to apply the method and produce a value. If it fails, # restores the input to the previous state.