module Pagy::StandaloneExtra

def pagy_url_for(pagy, page, absolute: false, html_escaped: false)

If there is a defined pagy.vars[:url] variable it does not need the params method nor Rack.
it works exactly as the regular #pagy_url_for, relying on the params method and Rack.
Return the URL for the page. If there is no pagy.vars[:url]
def pagy_url_for(pagy, page, absolute: false, html_escaped: false)
  return super unless pagy.vars[:url]
  vars                = pagy.vars
  page_param          = vars[:page_param].to_s
  items_param         = vars[:items_param].to_s
  params              = pagy.params.is_a?(Hash) ? pagy.params.clone : {}  # safe when it gets reused
  params[page_param]  = page
  params[items_param] = vars[:items] if vars[:items_extra]
  params              = pagy.params.call(params) if pagy.params.is_a?(Proc)
  query_string        = "?#{Rack::Utils.build_nested_query(params)}"
  query_string        = query_string.gsub('&', '&') if html_escaped  # the only unescaped entity
  "#{vars[:url]}#{query_string}#{vars[:fragment]}"
end