From 338aeeb5144f19b3995fc9c0cf6d11e686d4ae52 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 26 Aug 2014 21:08:50 +0200 Subject: [PATCH] Work around JRuby issue #1923. String#start_with?() returns false on JRuby when used with an empty string. See https://github.com/jruby/jruby/issues/1923 for more information. --- lib/oga/xpath/evaluator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 6f35130..b694c91 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -855,7 +855,8 @@ module Oga haystack_str = on_call_string(context, haystack) needle_str = on_call_string(context, needle) - return haystack_str.start_with?(needle_str) + # https://github.com/jruby/jruby/issues/1923 + return needle_str.empty? || haystack_str.start_with?(needle_str) end ##