diff --git a/web/executionUtils.js b/web/executionUtils.js index 702504c..9faea12 100644 --- a/web/executionUtils.js +++ b/web/executionUtils.js @@ -19,6 +19,9 @@ function convertPathsForPlatform(apiPrompt, targetSeparator) { const isLikelyFilename = (value) => { return value.match(/\.(ckpt|safetensors|pt|pth|bin|yaml|json|png|jpg|jpeg|webp|gif|bmp|latent|txt|vae|lora|embedding)(\s*\[\w+\])?$/i); }; + const isImageOrVideo = (value) => { + return value.match(/\.(png|jpg|jpeg|webp|gif|bmp|mp4|avi|mov|mkv|webm)(\s*\[\w+\])?$/i); + }; function convert(obj) { if (typeof obj === 'string') { @@ -29,12 +32,12 @@ function convertPathsForPlatform(apiPrompt, targetSeparator) { const isAbsolute = trimmed.startsWith('/') || trimmed.startsWith('\\\\'); const hasProtocol = /^\w+:\/\//.test(trimmed); - // Preserve annotated relative paths (e.g., "pasted/image.png") as forward slashes - if (!hasDrive && !isAbsolute && !hasProtocol) { - return trimmed.replace(/\\/g, '/'); + // For annotated relative image/video paths, keep forward slashes + if (!hasDrive && !isAbsolute && !hasProtocol && isImageOrVideo(trimmed)) { + return trimmed.replace(/[\\\\]/g, '/'); } - // Replace any path separator with the worker's target separator otherwise - return trimmed.replace(/[\\\/]/g, targetSeparator); + // Otherwise replace any path separator with the worker's target separator + return trimmed.replace(/[\\\\\/]/g, targetSeparator); } return obj; } else if (Array.isArray(obj)) { @@ -596,4 +599,4 @@ export async function performPreflightCheck(extension, workers) { }); return activeWorkers; -} \ No newline at end of file +}