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

Url.parse does not handle repeated query parameters correctly #31

Open
sqrrrl opened this issue Oct 2, 2015 · 1 comment
Open

Url.parse does not handle repeated query parameters correctly #31

sqrrrl opened this issue Oct 2, 2015 · 1 comment

Comments

@sqrrrl
Copy link
Contributor

sqrrrl commented Oct 2, 2015

Found an issue where flat parameters are discarded when passing in a URL to client.get. Specifically, I'm calling client.get(url) with an absolute URL that has a repeated parameter. Even though the client instance is configured to use the flat encoder, I'm seeing only the last value.

Looks like client.request is calling URL.join() to merge the URL with the base URL (in this case the base is null.) This is where it breaks:

Example:
Hurley::Url.join(nil, 'https://www.foo.com?a=b&a=b2')
#<Hurley::Url https://www.foo.com?a=b2>

Notice only the last value of a is preserved. Expected result is that both pairs would be retained.

@sqrrrl
Copy link
Contributor Author

sqrrrl commented Oct 2, 2015

Looks like changing the default query parser to flat helps a little if I change my code and re-apply the query:

client.get(url) do |req|
req.query.update query
end

But it still is a bug in that the initial parsing is broken.

It also is clear that Hurley is ignoring the client/request parser preference. req.query is coming back as Nested, even though the client is configured for flat. Since I'm using this in a library, I don't want to rely on having to change the default behavior as it could interfere with other usages.

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

1 participant