lib/pagy/extras/trim.rb in pagy-6.5.0 vs lib/pagy/extras/trim.rb in pagy-7.0.0
- old
+ new
@@ -7,11 +7,11 @@
# Remove the page=1 param from the first page link
module TrimExtra
# Override the original pagy_link_proc.
# Call the pagy_trim method if the trim_extra is enabled.
def pagy_link_proc(pagy, link_extra: '')
- link_proc = super(pagy, link_extra: link_extra)
+ link_proc = super(pagy, link_extra:)
return link_proc unless pagy.vars[:trim_extra]
lambda do |page, text = pagy.label_for(page), extra = ''|
link = +link_proc.call(page, text, extra)
return link unless page.to_s == '1'
@@ -20,10 +20,10 @@
end
end
# Remove the the :page_param param from the first page link
def pagy_trim(pagy, link)
- link.sub!(/(\?|&)#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/, '')
+ link.sub!(/[?&]#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/, '')
end
end
Frontend.prepend TrimExtra
end