fix: improve error handling for file URL processing
- Enhanced error handling in image reference detection to skip malformed file URLs without crashing. - Updated media loading logic to throw an error for invalid file URLs, ensuring better feedback for users.
This commit is contained in:
committed by
Peter Steinberger
parent
8c0e290db1
commit
ddcc05f5f4
@@ -128,8 +128,12 @@ export function detectImageReferences(prompt: string): DetectedImageRef[] {
|
||||
if (seen.has(raw.toLowerCase())) continue;
|
||||
seen.add(raw.toLowerCase());
|
||||
// Use fileURLToPath for proper handling (e.g., file://localhost/path)
|
||||
const resolved = fileURLToPath(raw);
|
||||
refs.push({ raw, type: "path", resolved });
|
||||
try {
|
||||
const resolved = fileURLToPath(raw);
|
||||
refs.push({ raw, type: "path", resolved });
|
||||
} catch {
|
||||
// Skip malformed file:// URLs
|
||||
}
|
||||
}
|
||||
|
||||
// Pattern for file paths (absolute, relative, or home)
|
||||
|
||||
Reference in New Issue
Block a user