mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	let import continue when malformed URLs are encountered
In case of malformed URLs in imported HTML, keep original URL instead of having the import get stuck.
This commit is contained in:
		
							parent
							
								
									d4658b9c2a
								
							
						
					
					
						commit
						fc69f3b8f3
					
				@ -292,7 +292,12 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
 | 
			
		||||
            content = content.replace(/<\/body>.*<\/html>/gis, "");
 | 
			
		||||
 | 
			
		||||
            content = content.replace(/src="([^"]*)"/g, (match, url) => {
 | 
			
		||||
                try {
 | 
			
		||||
                    url = decodeURIComponent(url);
 | 
			
		||||
                } catch (e) {
 | 
			
		||||
                    log.error(`Cannot parse image URL '${url}', keeping original (${e}).`);
 | 
			
		||||
                    return `src="${url}"`;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (isUrlAbsolute(url) || url.startsWith("/")) {
 | 
			
		||||
                    return match;
 | 
			
		||||
@ -304,7 +309,12 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            content = content.replace(/href="([^"]*)"/g, (match, url) => {
 | 
			
		||||
                try {
 | 
			
		||||
                    url = decodeURIComponent(url);
 | 
			
		||||
                } catch (e) {
 | 
			
		||||
                    log.error(`Cannot parse link URL '${url}', keeping original (${e}).`);
 | 
			
		||||
                    return `href="${url}"`;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (isUrlAbsolute(url)) {
 | 
			
		||||
                    return match;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user