fix: improve file URL handling and enhance image loading logic
- Added handling for file URLs using fileURLToPath for proper resolution. - Updated logic to skip relative path resolution if ref.resolved is already absolute. - Enhanced cap calculation for image loading to handle undefined maxBytes more gracefully.
This commit is contained in:
committed by
Peter Steinberger
parent
8d74578ceb
commit
7bfc77db25
@@ -163,6 +163,8 @@ export async function loadImageFromRef(
|
||||
// For file paths, resolve relative to the appropriate root:
|
||||
// - When sandbox is enabled, resolve relative to sandboxRoot for security
|
||||
// - Otherwise, resolve relative to workspaceDir
|
||||
// Note: ref.resolved may already be absolute (e.g., after ~ expansion in detectImageReferences),
|
||||
// in which case we skip relative resolution.
|
||||
if (ref.type === "path" && !path.isAbsolute(targetPath)) {
|
||||
const resolveRoot = options?.sandboxRoot ?? workspaceDir;
|
||||
targetPath = path.resolve(resolveRoot, targetPath);
|
||||
|
||||
Reference in New Issue
Block a user