Skip to content

Commit

Permalink
Supress warnings in Paperclip::UrlGenerator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
javierm committed Aug 25, 2021
1 parent 4557606 commit 79b1040
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/initializers/paperclip.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 79b1040

Please sign in to comment.