Skip to content

Commit

Permalink
Fix a URL generation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrayner committed Mar 20, 2018
1 parent 411c6c3 commit cba0f0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/parliament/request/base_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,21 @@ def handle_errors(response)
def separate_uri(query_url, query_params, additional_params)
endpoint = URI.parse(query_url)

temp_params = endpoint.query ? URI.decode_www_form(endpoint.query).to_h : {}
temp_params = {}

if endpoint.query
# Returns [ ["key", "value"], ["key", "value"] ]
key_value_array = URI.decode_www_form(endpoint.query)
key_value_array.map! { |key_value_pair| [ key_value_pair[0].to_sym, key_value_pair[1] ] }
temp_params = key_value_array.to_h
end

temp_params = temp_params.merge(query_params)
temp_params = temp_params.merge(additional_params) unless additional_params.nil?

endpoint.query = nil

encoded_params = URI.encode_www_form(temp_params.to_a) unless temp_params.empty?

{ endpoint: endpoint, params: encoded_params }
{ endpoint: endpoint, params: temp_params }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/parliament/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Parliament
VERSION = '1.0.0.pre4'.freeze
VERSION = '1.0.0.pre5'.freeze
end

0 comments on commit cba0f0a

Please sign in to comment.