mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Merge file and mime code into simple Common/File.js
This commit is contained in:
parent
cb2048f163
commit
9992b20163
9 changed files with 345 additions and 452 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { ComposeType, SaveSettingsStep, FolderType } from 'Common/Enums';
|
||||
import { Mime } from 'Common/Mime';
|
||||
|
||||
const
|
||||
doc = document,
|
||||
|
|
@ -820,39 +819,6 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getFileExtension(fileName) {
|
||||
fileName = fileName.toLowerCase().trim();
|
||||
|
||||
const result = fileName.split('.').pop();
|
||||
return result === fileName ? '' : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
* @returns {string}
|
||||
*/
|
||||
export function mimeContentType(fileName) {
|
||||
let ext = '',
|
||||
result = 'application/octet-stream';
|
||||
|
||||
fileName = fileName.toLowerCase().trim();
|
||||
|
||||
if ('winmail.dat' === fileName) {
|
||||
return 'application/ms-tnef';
|
||||
}
|
||||
|
||||
ext = getFileExtension(fileName);
|
||||
if (ext && ext.length && undefined !== Mime[ext]) {
|
||||
result = Mime[ext];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} color
|
||||
* @returns {boolean}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue