Fix deprecation warning in Paperclip

Fixes deprecation warnings in Paperclip::UrlGenerator#escape_url

On a side note: we shouldn't be using Paperclip at all, and should migrate to ActiveStorage.
This commit is contained in:
Matt-Yorkley
2021-09-29 12:51:32 +01:00
parent 5e658eb9dd
commit cb65c7c2ef

View File

@@ -28,3 +28,12 @@ if Paperclip::VERSION.to_f < 3.5
else
Rails.logger.warn "The Paperclip::GeometryDetector patch can now be removed."
end
module UpdatedUrlGenerator
def escape_url(url)
(url.respond_to?(:escape) ? url.escape : URI::Parser.new.escape(url)).
gsub(/(\/.+)\?(.+\.)/, '\1%3F\2')
end
end
Paperclip::UrlGenerator.prepend(UpdatedUrlGenerator)