You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Desktop, Cli: Give correct mime type to more file types
This commit is contained in:
@ -768,6 +768,9 @@ const mimeTypes = [
|
||||
{ t: 'x-conference/x-cooltalk', e: ['ice'] },
|
||||
];
|
||||
|
||||
// Note: if the list above is ever updated, make sure Markdown doesn't appear twice
|
||||
mimeTypes.push({ t: 'text/markdown', e: ['md', 'markdown'] });
|
||||
|
||||
const mime = {
|
||||
fromFileExtension(ext) {
|
||||
ext = ext.toLowerCase();
|
||||
@ -780,6 +783,13 @@ const mime = {
|
||||
return null;
|
||||
},
|
||||
|
||||
fromFilename(name) {
|
||||
if (!name) return null;
|
||||
const splitted = name.trim().split('.');
|
||||
if (splitted.length <= 1) return null;
|
||||
return mime.fromFileExtension(splitted[splitted.length - 1]);
|
||||
},
|
||||
|
||||
toFileExtension(mimeType) {
|
||||
mimeType = mimeType.toLowerCase();
|
||||
for (let i = 0; i < mimeTypes.length; i++) {
|
||||
|
@ -122,7 +122,6 @@ function shimInit() {
|
||||
|
||||
const { uuid } = require('lib/uuid.js');
|
||||
const { basename, fileExtension, safeFileExtension } = require('lib/path-utils.js');
|
||||
const mime = require('mime/lite');
|
||||
|
||||
if (!(await fs.pathExists(filePath))) throw new Error(_('Cannot access %s', filePath));
|
||||
|
||||
@ -132,7 +131,7 @@ function shimInit() {
|
||||
|
||||
let resource = Resource.new();
|
||||
resource.id = resourceId;
|
||||
resource.mime = mime.getType(filePath);
|
||||
resource.mime = mimeUtils.fromFilename(filePath);
|
||||
resource.title = basename(filePath);
|
||||
|
||||
let fileExt = safeFileExtension(fileExtension(filePath));
|
||||
|
Reference in New Issue
Block a user