From 35a5249607720ad86047bd14021a9833f5777318 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Wed, 5 Nov 2025 08:33:48 +0100 Subject: [PATCH] Improves remote image download protocol handling Ensures correct protocol (HTTP/HTTPS) is used when downloading remote images by using the parsed URL object for the request. This fixes potential issues where the protocol might be incorrectly determined, especially when dealing with case-insensitive URL schemes. --- src/plugin/EmbedProcessor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugin/EmbedProcessor.ts b/src/plugin/EmbedProcessor.ts index aba8d18..5df24b9 100644 --- a/src/plugin/EmbedProcessor.ts +++ b/src/plugin/EmbedProcessor.ts @@ -105,12 +105,13 @@ export class EmbedProcessor { const outputPath = path.join(tempDir, finalFileName); - // Select appropriate protocol - const protocol = imageUrl.startsWith('https') ? https : http; + // Select appropriate protocol based on parsed URL (handles case-insensitive schemes) + const protocol = urlObj.protocol === 'https:' ? https : http; console.log(`Export: Downloading remote image: ${imageUrl}`); - const request = protocol.get(imageUrl, (response) => { + // Use parsed URL object for the request to ensure correct protocol handling + const request = protocol.get(urlObj, (response) => { // Handle redirects if (response.statusCode === 301 || response.statusCode === 302) { const redirectUrl = response.headers.location;