mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	fix assigning extension to attachment export filenames, closes #4415
This commit is contained in:
		| @@ -75,15 +75,14 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) | |||||||
|      * @return {string} |      * @return {string} | ||||||
|      */ |      */ | ||||||
|     function getDataFileName(type, mime, baseFileName, existingFileNames) { |     function getDataFileName(type, mime, baseFileName, existingFileNames) { | ||||||
|         let fileName = baseFileName; |         let fileName = baseFileName.trim(); | ||||||
|  |         if (fileName.length > 30) { | ||||||
|  |             fileName = fileName.substr(0, 30).trim(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         let existingExtension = path.extname(fileName).toLowerCase(); |         let existingExtension = path.extname(fileName).toLowerCase(); | ||||||
|         let newExtension; |         let newExtension; | ||||||
|  |  | ||||||
|         if (fileName.length > 30) { |  | ||||||
|             fileName = fileName.substr(0, 30); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // the following two are handled specifically since we always want to have these extensions no matter the automatic detection |         // the following two are handled specifically since we always want to have these extensions no matter the automatic detection | ||||||
|         // and/or existing detected extensions in the note name |         // and/or existing detected extensions in the note name | ||||||
|         if (type === 'text' && format === 'markdown') { |         if (type === 'text' && format === 'markdown') { | ||||||
| @@ -108,7 +107,7 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // if the note is already named with extension (e.g. "jquery"), then it's silly to append the exact same extension again |         // if the note is already named with the extension (e.g. "image.jpg"), then it's silly to append the exact same extension again | ||||||
|         if (newExtension && existingExtension !== `.${newExtension.toLowerCase()}`) { |         if (newExtension && existingExtension !== `.${newExtension.toLowerCase()}`) { | ||||||
|             fileName += `.${newExtension}`; |             fileName += `.${newExtension}`; | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user