Fixes path, image, and bibliography issues #7
@@ -115,9 +115,13 @@ export class EmbedProcessor {
|
||||
if (response.statusCode === 301 || response.statusCode === 302) {
|
||||
const redirectUrl = response.headers.location;
|
||||
if (redirectUrl) {
|
||||
console.log(`Export: Following redirect to: ${redirectUrl}`);
|
||||
// Recursively follow redirect
|
||||
this.downloadRemoteImage(redirectUrl, tempDir).then(resolve);
|
||||
// Resolve relative redirects against the original request URL
|
||||
// This handles both absolute URLs (e.g., "https://example.com/img.png")
|
||||
// and relative URLs (e.g., "/assets/img.png" or "../img.png")
|
||||
const absoluteRedirectUrl = new URL(redirectUrl, imageUrl).href;
|
||||
console.log(`Export: Following redirect to: ${absoluteRedirectUrl}`);
|
||||
// Recursively follow redirect with resolved absolute URL
|
||||
this.downloadRemoteImage(absoluteRedirectUrl, tempDir).then(resolve);
|
||||
return;
|
||||
}
|
||||
|
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user
⚠️ Potential issue | 🟠 Major
Handle relative redirects when downloading images.
Redirects such as
Location: /assets/img.pngare valid butnew URL(redirectUrl)will throw without the original request as a base, causing every relative redirect download to fail. Pass the original URL tonew URL(...)(or otherwise resolve before recursing) so remote images behind relative redirects work.🤖 Prompt for AI Agents
✅ Addressed in commits
7ac9e1fto4eb52d1