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