Update executionUtils.js

Previous fix caused problems with loading models that are in subfolders like:
"'FLUX.1\\Shakker-Labs-ControlNet-Union-Pro-2.0.safetensors"

Now images and wideos are treated separetlly.
This commit is contained in:
Dominik Bargiel
2025-08-24 19:46:40 +02:00
committed by GitHub
parent 4b513d49c3
commit c860df0aa7
+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;
}
}