mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
fix(file): file.displayExtension should return lowercased extension
T2874
This commit is contained in:
parent
697a140ab8
commit
4df6d4f705
2 changed files with 11 additions and 2 deletions
|
@ -36,6 +36,14 @@ describe "File", ->
|
|||
f = new File(filename: 'a', contentType: 'image/jpg')
|
||||
expect(f.displayExtension()).toBe('')
|
||||
|
||||
it "should ignore the case of the extension i nthe filename", ->
|
||||
f = new File(filename: 'Hello world.JPG', contentType: 'image/jpg')
|
||||
expect(f.displayExtension()).toBe('jpg')
|
||||
f = new File(filename: 'Hello world.Jpg', contentType: 'image/jpg')
|
||||
expect(f.displayExtension()).toBe('jpg')
|
||||
f = new File(filename: 'Hello world.jpg', contentType: 'image/jpg')
|
||||
expect(f.displayExtension()).toBe('jpg')
|
||||
|
||||
it "should return an extension based on the default filename otherwise", ->
|
||||
f = new File(filename: '', contentType: 'image/jpg')
|
||||
expect(f.displayExtension()).toBe('jpg')
|
||||
|
|
|
@ -69,11 +69,12 @@ class File extends Model
|
|||
|
||||
# Public: Returns the file extension that should be used for this file.
|
||||
# Note that asking for the displayExtension is more accurate than trying to read
|
||||
# the extension directly off the filename, and may be based on contentType.
|
||||
# the extension directly off the filename. The returned extension may be based
|
||||
# on contentType and is always lowercase.
|
||||
#
|
||||
# Returns the extension without the leading '.' (ex: 'png', 'pdf')
|
||||
#
|
||||
displayExtension: ->
|
||||
path.extname(@displayName())[1..-1]
|
||||
path.extname(@displayName().toLowerCase())[1..-1]
|
||||
|
||||
module.exports = File
|
||||
|
|
Loading…
Reference in a new issue