Supress warnings in Paperclip::UrlGenerator

We were getting hundreds of "warning: URI.escape is obsolete" messages.
So we're using `URI::DEFAULT_PARSER.escape` instead.

IMHO it's OK to add this monkey-patch because we're replacing Paperclip
with Active Storage, and when we finish with that we'll delete this
file.
This commit is contained in:
Javi Martín
2021-08-15 21:17:40 +02:00
parent f2330bee2b
commit 4f4f8f6180

View File

@@ -0,0 +1,13 @@
class Paperclip::UrlGenerator
private
# Code copied from the paperclip gem, only replacing
# `URI.escape` with `URI::DEFAULT_PARSER.escape`
def escape_url(url)
if url.respond_to?(:escape)
url.escape
else
URI::DEFAULT_PARSER.escape(url).gsub(escape_regex) { |m| "%#{m.ord.to_s(16).upcase}" }
end
end
end