Skip to content

Commit

Permalink
small improvement to pagy_url_for
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Apr 25, 2021
1 parent 2acbac6 commit 2faca63
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/pagy/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def pagy_url_for(pagy, page, url=nil)
p_vars = pagy.vars
params = request.GET.merge(p_vars[:params])
params[p_vars[:page_param].to_s] = page
"#{request.base_url if url}#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{p_vars[:anchor]}"
query_string = "?#{Rack::Utils.build_nested_query(pagy_get_params(params))}" unless params.empty?
"#{request.base_url if url}#{request.path}#{query_string}#{p_vars[:anchor]}"
end

# Sub-method called only by #pagy_url_for: here for easy customization of params by overriding
Expand Down

0 comments on commit 2faca63

Please sign in to comment.