fixes of new attachment URLs

This commit is contained in:
zadam
2023-04-17 22:40:53 +02:00
parent b84670d503
commit 0e4a040ed8
6 changed files with 2742 additions and 65 deletions

View File

@@ -435,7 +435,7 @@ const downloadImagePromises = {};
function replaceUrl(content, url, attachment) {
const quotedUrl = utils.quoteRegex(url);
return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "ig"), ` src="api/notes/${attachment.parentId}/images/${encodeURIComponent(attachment.title)}"`);
return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "ig"), ` src="api/attachments/${encodeURIComponent(attachment.title)}/image"`);
}
function downloadImages(noteId, content) {
@@ -461,7 +461,7 @@ function downloadImages(noteId, content) {
content = `${content.substr(0, imageMatch.index)}<img src="api/images/${note.noteId}/${sanitizedTitle}"${content.substr(imageMatch.index + imageMatch[0].length)}`;
}
else if (!url.includes('api/images/') && !/api\/notes\/.+\/images\/.*/.test(url)
else if (!url.includes('api/images/') && !/api\/attachments\/.+\/image\/?.*/.test(url)
// this is an exception for the web clipper's "imageId"
&& (url.length !== 20 || url.toLowerCase().startsWith('http'))) {