From c7d7f6b28bfcfad7618f19754795e7d9fb2b85f1 Mon Sep 17 00:00:00 2001 From: a5-stable Date: Sun, 26 Mar 2023 14:20:32 +0900 Subject: [PATCH] skip when node size is zero --- lib/jsonpath/enumerable.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/jsonpath/enumerable.rb b/lib/jsonpath/enumerable.rb index 62dd71f..94926cb 100644 --- a/lib/jsonpath/enumerable.rb +++ b/lib/jsonpath/enumerable.rb @@ -64,6 +64,7 @@ def handle_wildecard(node, expr, _context, _key, pos, &blk) else next if node.is_a?(Array) && node.empty? next if node.nil? # when default_path_leaf_to_null is true + next if node.size.zero? array_args = sub_path.split(':') if array_args[0] == '*' @@ -81,6 +82,7 @@ def handle_wildecard(node, expr, _context, _key, pos, &blk) next unless end_idx next if start_idx == end_idx && start_idx >= node.size end + start_idx %= node.size end_idx %= node.size step = process_function_or_literal(array_args[2], 1)