From 804a5afa1b3e13cbc11ce4983fc61927b4e7da97 Mon Sep 17 00:00:00 2001 From: Joshua Hull Date: Tue, 9 May 2023 09:20:49 +0200 Subject: [PATCH] Handle any failure to match a token --- lib/jsonpath.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/jsonpath.rb b/lib/jsonpath.rb index fff66e1..238a7bd 100644 --- a/lib/jsonpath.rb +++ b/lib/jsonpath.rb @@ -44,12 +44,10 @@ def initialize(path, opts = {}) nil elsif (token = scanner.scan(/[><=] \d+/)) @path.last << token - elsif (token = scanner.scan(/./m)) - begin - @path.last << token - rescue RuntimeError - raise ArgumentError, "character '#{token}' not supported in query" - end + elsif (token = scanner.scan(/./)) + @path.last << token + else + raise ArgumentError, "character '#{scanner.peek(1)}' not supported in query" end end end