lib/file_locator.rb in active_encode-0.8.2 vs lib/file_locator.rb in active_encode-1.0.0

- old
+ new

@@ -8,12 +8,12 @@ class S3File attr_reader :bucket, :key def initialize(uri) uri = Addressable::URI.parse(uri) - @bucket = URI.decode(uri.host) - @key = URI.decode(uri.path).sub(%r{^/*(.+)/*$}, '\1') + @bucket = Addressable::URI.unencode(uri.host) + @key = Addressable::URI.unencode(uri.path).sub(%r{^/*(.+)/*$}, '\1') end def object @object ||= Aws::S3::Object.new(bucket_name: bucket, key: key) end @@ -24,35 +24,35 @@ end def uri if @uri.nil? if source.is_a? File - @uri = Addressable::URI.parse("file://#{URI.encode(File.expand_path(source))}") + @uri = Addressable::URI.parse("file://#{Addressable::URI.encode(File.expand_path(source))}") else encoded_source = source begin @uri = Addressable::URI.parse(encoded_source) rescue URI::InvalidURIError if encoded_source == source - encoded_source = URI.encode(encoded_source) + encoded_source = Addressable::URI.encode(encoded_source) retry else raise end end - @uri = Addressable::URI.parse("file://#{URI.encode(File.expand_path(source))}") if @uri.scheme.nil? + @uri = Addressable::URI.parse("file://#{Addressable::URI.encode(File.expand_path(source))}") if @uri.scheme.nil? end end @uri end def location case uri.scheme when 's3' S3File.new(uri).object.presigned_url(:get) when 'file' - URI.decode(uri.path) + Addressable::URI.unencode(uri.path) else @uri.to_s end end