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
@@ -27,7 +27,11 @@ async function loadWebMediaInternal(
|
||||
const { maxBytes, optimizeImages = true } = options;
|
||||
// Use fileURLToPath for proper handling of file:// URLs (handles file://localhost/path, etc.)
|
||||
if (mediaUrl.startsWith("file://")) {
|
||||
mediaUrl = fileURLToPath(mediaUrl);
|
||||
try {
|
||||
mediaUrl = fileURLToPath(mediaUrl);
|
||||
} catch {
|
||||
throw new Error(`Invalid file:// URL: ${mediaUrl}`);
|
||||
}
|
||||
}
|
||||
|
||||
const optimizeAndClampImage = async (buffer: Buffer, cap: number) => {
|
||||
|
||||
Reference in New Issue
Block a user