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

Commas in GET URIs being transformed into %2C #35

Open
thescubageek opened this issue Nov 4, 2024 · 1 comment
Open

Commas in GET URIs being transformed into %2C #35

thescubageek opened this issue Nov 4, 2024 · 1 comment

Comments

@thescubageek
Copy link

thescubageek commented Nov 4, 2024

When you pass in a request that uses , in the query params (which is how X handles user.fields etc) it is being transformed into %2C which causes those custom fields to fail to be fetched from X.

I was able to fix this locally by changing the following

  def escape_query_params(uri)
      URI(uri).tap do |u|
        u.query = URI.encode_www_form(URI.decode_www_form(u.query)).gsub("%2C", ",") if u.query
      end
    end
@thescubageek
Copy link
Author

I would push the fix myself for a PR but I'm getting a 403. I changed the code above and also added this test

    def test_escape_query_params_with_commas
      uri = "https://api.twitter.com/2/tweets/search/recent?query=%23ruby&expansions=author_id&user.fields=id,name,username"
      request = @request_builder.build(http_method: :post, uri:, authenticator: @authenticator)

      assert_equal "query=%23ruby&expansions=author_id&user.fields=id,name,username", request.uri.query
    end

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