lib/airborne/path_matcher.rb in airborne-0.1.9 vs lib/airborne/path_matcher.rb in airborne-0.1.10

- old
+ new

@@ -1,11 +1,11 @@ module Airborne class PathError < StandardError; end module PathMatcher def get_by_path(path, json, &block) - raise PathError, "Ivalid Path, contains '..'" if /\.\./ =~ path + raise PathError, "Invalid Path, contains '..'" if /\.\./ =~ path type = false parts = path.split('.') parts.each_with_index do |part, index| if part == '*' || part == '?' ensure_array(path, json) @@ -49,10 +49,10 @@ ensure_match_one(path, item_count, error_count) if type == '?' end end def process_json(part, json) - if is_index?(part) + if is_index?(part) && json.is_a?(Array) part = part.to_i json = json[part] else json = json[part.to_sym] end