Skip to content

Commit

Permalink
fix: add missing params_hash_has_key
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 10, 2020
1 parent b6cd3c0 commit 700efa7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/pact/consumer_contract/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ def self.params_hash_type?(obj)
obj.is_a?(Hash)
end

def self.params_hash_has_key?(hash, key)
return false if /\[\]/.match?(key)

key.split(/[\[\]]+/).inject(hash) do |h, part|
next h if part == ''
return false unless params_hash_type?(h) && h.key?(part)
h[part]
end

true
end

def self.unescape(s, encoding = Encoding::UTF_8)
URI.decode_www_form_component(s, encoding)
end
Expand Down

0 comments on commit 700efa7

Please sign in to comment.