Fixes path, image, and bibliography issues #7
@@ -91,14 +91,17 @@ export class EmbedProcessor {
|
||||
// Parse URL to get filename
|
||||
const urlObj = new URL(imageUrl);
|
||||
const urlPath = urlObj.pathname;
|
||||
const fileName = path.basename(urlPath) || `remote-image-${Date.now()}.png`;
|
||||
const fileName = path.basename(urlPath) || `remote-image-${Date.now()}`;
|
||||
|
||||
// Ensure we have a valid file extension
|
||||
// Extract extension and normalize it (lowercase)
|
||||
const ext = path.extname(fileName).toLowerCase();
|
||||
const validExtensions = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.tiff'];
|
||||
const finalFileName = validExtensions.includes(ext)
|
||||
? fileName
|
||||
: `${fileName}.png`;
|
||||
|
||||
// Preserve any existing extension, or append .png if no extension present
|
||||
// This handles all image types (svg, ico, avif, etc.) without forcing .png
|
||||
const finalFileName = ext
|
||||
? fileName // Has an extension, preserve it
|
||||
: `${fileName}.png`; // No extension, append .png
|
||||
|
||||
const outputPath = path.join(tempDir, finalFileName);
|
||||
|
|
||||
|
||||
|
||||
Reference in new issue
Block a user
⚠️ Potential issue | 🟠 Major
Preserve original image extensions instead of forcing
.png.When a remote file ends with something like
.svg, we append.pngwithout converting the contents. That leaves us with an SVG payload masquerading as PNG, so Typst/Pandoc will fail to decode the asset. Please keep the on-disk extension if one is present (at least include.svg,.ico, etc. invalidExtensions, or only fall back to.pngwhen the URL truly lacks an extension). Based on learnings🤖 Prompt for AI Agents
✅ Addressed in commits
7ac9e1fto4eb52d1