Commit 94eb2916 by Jon Yurek

Formatting and anchoring the extension gsub to the end

parent 7d29d06d
...@@ -74,11 +74,11 @@ module Paperclip ...@@ -74,11 +74,11 @@ module Paperclip
return nil if uploaded_file.nil? return nil if uploaded_file.nil?
logger.info("[paperclip] Writing attributes for #{name}") logger.info("[paperclip] Writing attributes for #{name}")
@queued_for_write[:original] = uploaded_file.to_tempfile @queued_for_write[:original] = uploaded_file.to_tempfile
instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_')) instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_'))
instance_write(:content_type, uploaded_file.content_type.strip) instance_write(:content_type, uploaded_file.content_type.strip)
instance_write(:file_size, uploaded_file.size.to_i) instance_write(:file_size, uploaded_file.size.to_i)
instance_write(:updated_at, Time.now) instance_write(:updated_at, Time.now)
@dirty = true @dirty = true
...@@ -169,7 +169,7 @@ module Paperclip ...@@ -169,7 +169,7 @@ module Paperclip
attachment.instance.class.name.underscore.pluralize attachment.instance.class.name.underscore.pluralize
end, end,
:basename => lambda do |attachment,style| :basename => lambda do |attachment,style|
attachment.original_filename.gsub(File.extname(attachment.original_filename), "") attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
end, end,
:extension => lambda do |attachment,style| :extension => lambda do |attachment,style|
((style = attachment.styles[style]) && style.last) || ((style = attachment.styles[style]) && style.last) ||
......
...@@ -174,7 +174,6 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -174,7 +174,6 @@ class AttachmentTest < Test::Unit::TestCase
should "strip whitespace from content_type field" do should "strip whitespace from content_type field" do
assert_equal "image/png", @dummy.avatar.instance.avatar_content_type assert_equal "image/png", @dummy.avatar.instance.avatar_content_type
end end
end end
context "Attachment with strange letters" do context "Attachment with strange letters" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment