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

Fixed an issue where the URL is not correctly created if "[]" is included in the query parameter #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/kaminari/helpers/sinatra_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def link_to_unless(condition, name, options = {}, html_options = {}, &block)
# In that case, please add `template: self` option when calling this method.
def paginate(scope, options = {})
current_path = env['PATH_INFO'] rescue nil
current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}
current_params = Rack::Utils.parse_query(env['QUERY_STRING']).map{|k, v| [k.delete("[]"), v]}.to_h.symbolize_keys rescue {}

template = ActionViewTemplateProxy.new current_params: current_params, current_path: current_path, param_name: options[:param_name] || Kaminari.config.param_name

Expand Down
6 changes: 6 additions & 0 deletions test/helpers/sinatra_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ def last_document
assert_match(/user_page=\d+/, elm.attribute('href').value)
end
end

test 'Include nested query in query' do
get '/users', attribute: [:adult, :children]

assert_match(/users\?attribute%5B%5D=adult&attribute%5B%5D=children/, last_document.search('a').attribute('href').value)
end
end
end

Expand Down