闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
489 B

  1. # frozen_string_literal: true
  2. module Paperclip
  3. module UrlGeneratorExtensions
  4. # Monkey-patch Paperclip to use Addressable::URI's normalization instead
  5. # of the long-deprecated URI.esacpe
  6. def escape_url(url)
  7. if url.respond_to?(:escape)
  8. url.escape
  9. else
  10. Addressable::URI.parse(url).normalize.to_str.gsub(escape_regex) { |m| "%#{m.ord.to_s(16).upcase}" }
  11. end
  12. end
  13. end
  14. end
  15. Paperclip::UrlGenerator.prepend(Paperclip::UrlGeneratorExtensions)