thoughtbot/paperclip

View on GitHub
lib/paperclip/io_adapters/http_url_proxy_adapter.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Paperclip
  class HttpUrlProxyAdapter < UriAdapter
    def self.register
      Paperclip.io_adapters.register self do |target|
        String === target && target =~ REGEXP
      end
    end

    REGEXP = /\Ahttps?:\/\//

    def initialize(target, options = {})
      escaped = URI.escape(target)
      super(URI(target == URI.unescape(target) ? escaped : target), options)
    end
  end
end