Skip to content

Commit 7ba5cf0

Browse files
committed
Replace CGI.parse with URI.decode_www_form for Ruby 4.0 compatibility
Ruby 4.0 removed `CGI.parse`. Use `URI.decode_www_form` instead and shape the result as `Hash<String, Array<String>>` to keep the existing callers (which expect array values) working without changes. Compatible with Ruby 2.7 through 4.0.
1 parent b58ae6f commit 7ba5cf0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/devise_token_auth/rails/routes.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def mount_devise_token_auth_for(resource, opts)
7676
match "#{full_path}/:provider", to: redirect(status: 307) { |params, request|
7777
# get the current querystring
7878
# TODO: deprecate in favor of using params
79-
qs = CGI::parse(request.env['QUERY_STRING'].empty? ? request.body.read : request.env['QUERY_STRING'] )
79+
query_string = request.env['QUERY_STRING'].empty? ? request.body.read : request.env['QUERY_STRING']
80+
qs = URI.decode_www_form(query_string).group_by(&:first).transform_values { |pairs| pairs.map(&:last) }
8081

8182
# append name of current resource
8283
qs['resource_class'] = [resource]

0 commit comments

Comments
 (0)