From 496811a23fa7c3f0498ec5721575b1c8406a5351 Mon Sep 17 00:00:00 2001 From: Daniel Fockler Date: Fri, 14 Aug 2015 16:15:49 -0700 Subject: [PATCH] Fixes #127 --- lib/oga/xpath/evaluator.rb | 4 +++- spec/oga/xpath/evaluator/general_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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