diff --git a/app/logical/downloads/file.rb b/app/logical/downloads/file.rb index 5e0c9ea31..cd7f8f61d 100644 --- a/app/logical/downloads/file.rb +++ b/app/logical/downloads/file.rb @@ -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 diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index d325ad52f..424b68e90 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -36,7 +36,7 @@
<%= 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 %>