diff --git a/lib/pact/consumer_contract/query.rb b/lib/pact/consumer_contract/query.rb index 0a46ec7..af91613 100644 --- a/lib/pact/consumer_contract/query.rb +++ b/lib/pact/consumer_contract/query.rb @@ -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