Merge pull request #32 from doubletwisted/fix/pasted-paths

Update executionUtils.js
This commit is contained in:
Robert Wojciechowski
2025-08-25 13:37:34 +10:00
committed by GitHub
+9 -6
View File
@@ -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;
}
}