Skip to content

Commit

Permalink
Fix warning in ruby 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
huobazi committed Dec 30, 2019
1 parent d01a608 commit 7aa4616
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -191,4 +191,4 @@ DEPENDENCIES
sqlite3

BUNDLED WITH
1.17.3
2.1.2
8 changes: 7 additions & 1 deletion lib/carrierwave/storage/qiniu.rb
Expand Up @@ -89,7 +89,7 @@ def get(path)
end

def download_url(path)
encode_path = URI.escape(path) #fix chinese file name, same as encodeURIComponent in js but preserve slash '/'
encode_path = path_escape(path)
primitive_url = "#{@qiniu_protocol}://#{@qiniu_bucket_domain}/#{encode_path}"
@qiniu_bucket_private ? \
::Qiniu::Auth.authorize_download_url(primitive_url, :expires_in => @qiniu_private_url_expires_in) \
Expand Down Expand Up @@ -119,6 +119,12 @@ def init_qiniu_rs_connection

end

#fix chinese file name, same as encodeURIComponent in js but preserve slash '/'
def path_escape(value)
#CGI.escape(value)#.gsub("%2F", "/")
::URI::DEFAULT_PARSER.escape value
end

end

class File
Expand Down
6 changes: 3 additions & 3 deletions spec/upload_spec.rb
Expand Up @@ -102,13 +102,13 @@ class WrongPhoto < ActiveRecord::Base
puts 'The image was uploaded to:'
puts photo.image.url

open(photo.image.url).should_not be_nil
URI.open(photo.image.url).should_not be_nil


puts "The thumb image:"
puts photo.image.url(:thumb)

open(photo.image.thumb.url).should_not be_nil
URI.open(photo.image.thumb.url).should_not be_nil

end

Expand All @@ -129,7 +129,7 @@ class WrongPhoto < ActiveRecord::Base

expect(photo2.image.url).not_to eq(photo.image.url)

open(photo2.image.url).should_not be_nil
URI.open(photo2.image.url).should_not be_nil
end

describe 'after remove' do
Expand Down

0 comments on commit 7aa4616

Please sign in to comment.