Skip to content

Commit

Permalink
Fix OR expressions where the left side is true
Browse files Browse the repository at this point in the history
TrueClass does not respond to `#empty?`, which makes `foo || bar` where foo resolves to true fail.
  • Loading branch information
iconara committed Jan 11, 2016
1 parent 3ff239a commit 0884f19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jmespath/nodes/or.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(left, right)

def visit(value)
result = @left.visit(value)
if result == false || result.nil? || result.empty?
if result == false || result.nil? || (result.respond_to?(:empty?) && result.empty?)
@right.visit(value)
else
result
Expand Down

0 comments on commit 0884f19

Please sign in to comment.