mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	improvements in the exported file extensions
This commit is contained in:
		
							parent
							
								
									b9373806cf
								
							
						
					
					
						commit
						a76dcb44ae
					
				@ -46,24 +46,32 @@ async function exportToTar(exportContext, branch, format, res) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function getDataFileName(note, baseFileName, existingFileNames) {
 | 
					    function getDataFileName(note, baseFileName, existingFileNames) {
 | 
				
			||||||
        let extension;
 | 
					        const existingExtension = path.extname(baseFileName).toLowerCase();
 | 
				
			||||||
 | 
					        let newExtension;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 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
 | 
				
			||||||
        if (note.type === 'text' && format === 'markdown') {
 | 
					        if (note.type === 'text' && format === 'markdown') {
 | 
				
			||||||
            extension = 'md';
 | 
					            newExtension = 'md';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (note.type === 'text' && format === 'html') {
 | 
				
			||||||
 | 
					            newExtension = 'html';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (note.mime === 'application/x-javascript' || note.mime === 'text/javascript') {
 | 
					        else if (note.mime === 'application/x-javascript' || note.mime === 'text/javascript') {
 | 
				
			||||||
            extension = 'js';
 | 
					            newExtension = 'js';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (existingExtension.length > 0) { // if the page already has an extension, then we'll just keep it
 | 
				
			||||||
 | 
					            newExtension = null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            extension = mimeTypes.extension(note.mime) || "dat";
 | 
					            newExtension = mimeTypes.extension(note.mime) || "dat";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let fileName = baseFileName;
 | 
					        let fileName = baseFileName;
 | 
				
			||||||
        const existingExtension = path.extname(fileName).toLowerCase();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // if the note is already named with extension (e.g. "jquery.js"), then it's silly to append exact same extension again
 | 
					        // if the note is already named with extension (e.g. "jquery.js"), then it's silly to append exact same extension again
 | 
				
			||||||
        if (existingExtension !== "." + extension) {
 | 
					        if (newExtension && existingExtension !== "." + newExtension.toLowerCase()) {
 | 
				
			||||||
            fileName += "." + extension;
 | 
					            fileName += "." + newExtension;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return getUniqueFilename(existingFileNames, fileName);
 | 
					        return getUniqueFilename(existingFileNames, fileName);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user