Strip source whitespace before upload

This was already done for post edits but not on upload.
This commit is contained in:
Toks
2015-10-04 16:57:40 -04:00
parent f694c780c6
commit b12b637568

View File

@@ -102,6 +102,7 @@ class Upload < ActiveRecord::Base
def process_once
CurrentUser.scoped(uploader, uploader_ip_addr) do
update_attribute(:status, "processing")
self.source = strip_source
if is_downloadable?
self.source = download_from_source(temp_file_path)
end
@@ -379,6 +380,10 @@ class Upload < ActiveRecord::Base
end
module DownloaderMethods
def strip_source
source.try(:strip)
end
# Determines whether the source is downloadable
def is_downloadable?
source =~ /^https?:\/\// && file_path.blank?