HTTParty将params from:options多次添加到URL

时间:2013-10-11 15:58:56

标签: ruby-on-rails api uri params httparty

HTTParty.get正在多次向其发送的URI添加参数。有没有其他人遇到过这个?

def initialize(address)
   self.address = address
   self.base_uri = 'https://api.randomapi.com/street-address'
end

def get
  response = HTTParty.get(base_uri, :query => {
    :street => address.street.strip,
  })
end

如果这样我以这种方式格式化请求:

HTTParty.get(base_uri, :query => {:street=>"random street"})

这是URI发送。注意添加street param的次数。

#<URI::HTTPS:0x007fbc78582d70 URL:https://api.randomapi.com/street-address?street=random%20street&street=random%20street&street=random%20street&street=random%20street>

1 个答案:

答案 0 :(得分:1)

原来这是宝石中的一个错误(https://github.com/jnunemaker/httparty/issues/185https://github.com/jnunemaker/httparty/pull/189)。我升级到0.11并修复了重复参数问题。