Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API does not accepted encoded query string params #2

Open
NathanielWroblewski opened this issue Mar 11, 2014 · 4 comments
Open

API does not accepted encoded query string params #2

NathanielWroblewski opened this issue Mar 11, 2014 · 4 comments

Comments

@NathanielWroblewski
Copy link
Contributor

API breaks when passed encoded values instead of actual values. For example:

encodeURIComponent('=')
> "%3D"
encodeURIComponent('&')
> "%26"

This breaks when passing multiple parameters.

%26addresses%3Dmu1izpJmF7CHnbVcH59f1PqfvXnmiBEMq8
&addresses=mu1izpJmF7CHnbVcH59f1PqfvXnmiBEMq8
@scottlingran
Copy link
Member

@NathanielWroblewski, how did the urls become encoded?

I'm a bit hesitant to handle this because even the following will break
www.google.com/search?q%3Dhello

@NathanielWroblewski
Copy link
Contributor Author

Faraday.

@scottlingran
Copy link
Member

require 'faraday'
require 'json'

conn = Faraday.new(:url => 'https://testnet.helloblock.io') do |faraday|
  faraday.request  :url_encoded
  faraday.response :logger
  faraday.adapter  Faraday.default_adapter
end


response = conn.get do |req|
  req.url '/wallet'
  req.params['addresses'] = ["mpjuaPusdVC5cKvVYCFX94bJX1SNUY8EJo"]
end

url = response.env.url.to_s
p url
# => https://testnet.helloblock.io/wallet?addresses%5B%5D=mpjuaPusdVC5cKvVYCFX94bJX1SNUY8EJo

body = JSON.parse(response.body)
p body
# seems fine

@scottlingran
Copy link
Member

How was that bug produced?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants