Skip to content

Commit

Permalink
fixed specs and include extension in cleaned_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
ncri committed Oct 20, 2014
1 parent 63719d1 commit 98be217
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ $.fn.S3Uploader = (options) ->
name: "content-type"
value: fileType

filename = @files[0].name.replace(/\.[^/.]+$/, '')
cleaned_filename = @files[0].name.replace(/\s/g, '_').replace(/[^\w.-]/gi, '')
key = $uploadForm.data("key")
.replace('{timestamp}', new Date().getTime())
.replace('{unique_id}', @files[0].unique_id)
.replace('{cleaned_filename}', filename.replace(/\s/g, '_').replace(/[^\w.-]/gi, ''))
.replace('{cleaned_filename}', cleaned_filename)
.replace('{extension}', @files[0].name.split('.').pop())

# substitute upload timestamp and unique_id into key
Expand Down
4 changes: 2 additions & 2 deletions spec/existance_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spec_helper'
describe S3DirectUpload do
it "version must be defined" do
S3DirectUpload::VERSION.should be_true
S3DirectUpload::VERSION.should be_present
end

it "config must be defined" do
S3DirectUpload.config.should be_true
S3DirectUpload.config.should be_present
end

end

0 comments on commit 98be217

Please sign in to comment.