diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index dee0045..07cd721 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -1691,7 +1691,9 @@ module Oga def name_matches?(xml_node, name) return false unless xml_node.respond_to?(:name) - name == STAR ? true : xml_node.name == name + return true if name == STAR + + xml_node.name == name || xml_node.name.downcase == name.downcase end ## diff --git a/spec/oga/xpath/evaluator/general_spec.rb b/spec/oga/xpath/evaluator/general_spec.rb index b66eabb..930cce2 100644 --- a/spec/oga/xpath/evaluator/general_spec.rb +++ b/spec/oga/xpath/evaluator/general_spec.rb @@ -92,6 +92,12 @@ describe Oga::XPath::Evaluator do @evaluator.node_matches?(text, s(:test, nil, 'a')).should == false end + + it 'returns true if a node is matched case insensitively' do + node = Oga::XML::Element.new(:name => 'DiV') + + @evaluator.node_matches?(node, s(:test, nil, 'div')).should == true + end end describe 'with a custom namespace' do