Reconstruct query string from request

(1) Create a hash from query parameters. Sort the keys if needed.

r = Hash[request.query_parameters.sort]

(2) Loop the hash to reconstruct the query string.

query_string = ''
r.each {|k,v| query_string << "#{k}=#{v}&" }

(3) Remove the last & character.

query_string = query_string[0...-1]



AI Summary
Chrome On-device AI 2024-10-04 22:50:40

Share Article