Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Error when trying to show preview of undefined filetype #6935

Merged
merged 2 commits into from
May 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/rocketchat-ui/client/lib/fileUpload.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ getUploadPreview = (file, callback) ->
# If greater then 10MB don't try and show a preview
if file.file.size > 10 * 1000000
callback(file, null)
else if file.file.type is undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe testing any falsy value would be safier.. what do you think? like else if not file.file.type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course 👍 makes sense. That's coffeescript for you lol

callback(file, null)
else
if file.file.type.indexOf('audio') > -1 or file.file.type.indexOf('video') > -1 or file.file.type.indexOf('image') > -1
file.type = file.file.type.split('/')[0]
Expand Down