lib/pagy/extras/trim.rb in pagy-4.2.0 vs lib/pagy/extras/trim.rb in pagy-4.3.0
- old
+ new
@@ -1,20 +1,20 @@
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/trim
# frozen_string_literal: true
class Pagy
+ VARS[:trim] = true
+
module UseTrimExtra
def pagy_link_proc(pagy, link_extra='')
link_proc = super(pagy, link_extra)
+ return link_proc unless pagy.vars[:trim]
lambda do |num, text=num, extra=''|
link = link_proc.call(num, text, extra)
- if num == 1
- link.sub!(/[?&]#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/, '')
- else
- link
- end
+ return link unless num == 1
+ link.sub!(/[?&]#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/, '')
end
end
end
Frontend.prepend UseTrimExtra