Skip to content

Commit 804a5af

Browse files
committed
Handle any failure to match a token
1 parent 2c7cea8 commit 804a5af

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/jsonpath.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ def initialize(path, opts = {})
4444
nil
4545
elsif (token = scanner.scan(/[><=] \d+/))
4646
@path.last << token
47-
elsif (token = scanner.scan(/./m))
48-
begin
49-
@path.last << token
50-
rescue RuntimeError
51-
raise ArgumentError, "character '#{token}' not supported in query"
52-
end
47+
elsif (token = scanner.scan(/./))
48+
@path.last << token
49+
else
50+
raise ArgumentError, "character '#{scanner.peek(1)}' not supported in query"
5351
end
5452
end
5553
end

0 commit comments

Comments
 (0)