potential fix for #2328
This commit is contained in:
@@ -3,12 +3,13 @@ module Downloads
|
||||
class Error < Exception ; end
|
||||
|
||||
attr_reader :data, :options
|
||||
attr_accessor :source, :content_type, :file_path
|
||||
attr_accessor :source, :original_source, :content_type, :file_path
|
||||
|
||||
def initialize(source, file_path, options = {})
|
||||
# source can potentially get rewritten in the course
|
||||
# of downloading a file, so check it again
|
||||
@source = source
|
||||
@original_source = source
|
||||
|
||||
# where to save the download
|
||||
@file_path = file_path
|
||||
@@ -41,6 +42,7 @@ module Downloads
|
||||
|
||||
def after_download(src)
|
||||
fix_image_board_sources(src)
|
||||
fix_twitter_sources(src)
|
||||
end
|
||||
|
||||
def http_get_streaming(src, datums = {}, options = {})
|
||||
@@ -106,5 +108,13 @@ module Downloads
|
||||
src
|
||||
end
|
||||
end
|
||||
|
||||
def fix_twitter_sources(src)
|
||||
if src =~ %r!^https?://pbs\.twimg\.com/! && original_source =~ %r!^https?://twitter\.com/!
|
||||
original_source
|
||||
else
|
||||
src
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<div class="input">
|
||||
<%= f.label :source %>
|
||||
<% if params[:url].present? %>
|
||||
<%= f.text_field :source, :size => 50, :value => @normalized_url %>
|
||||
<%= f.text_field :source, :size => 50, :value => params[:url] %>
|
||||
<% else %>
|
||||
<%= f.text_field :source, :size => 50 %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user