mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 03:01:27 -03:00
fix(lora-loader): preserve repeated spaces inside lora names
Whitespace cleanup in cleanupLoraSyntax() and the autocomplete blur formatter collapsed all whitespace runs, including inside <lora:...> tags. A file named 'test - 0021.safetensors' was rewritten to 'test - 0021' in the node text, so runtime file resolution failed. Protect lora tags with placeholders (or segment splitting) so only whitespace between entries is normalized; names inside tags are kept byte-for-byte.
This commit is contained in:
@@ -38,7 +38,17 @@ function cleanupLoraSyntax(text) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let cleaned = text
|
||||
// Protect <lora:...> tags with placeholders before cleanup: names inside
|
||||
// the tags may legitimately contain repeated spaces or commas (e.g.
|
||||
// "test - 0021"), and collapsing them breaks file resolution at runtime.
|
||||
const protectedTags = [];
|
||||
LORA_PATTERN.lastIndex = 0;
|
||||
const masked = text.replace(LORA_PATTERN, (match) => {
|
||||
protectedTags.push(match);
|
||||
return `\u0000${protectedTags.length - 1}\u0000`;
|
||||
});
|
||||
|
||||
let cleaned = masked
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(/,\s*,+/g, ",")
|
||||
.replace(/\s*,\s*/g, ",")
|
||||
@@ -51,7 +61,9 @@ function cleanupLoraSyntax(text) {
|
||||
cleaned = cleaned.replace(/(^,)|(,$)/g, "");
|
||||
cleaned = cleaned.replace(/,\s*/g, ", ");
|
||||
|
||||
return cleaned.trim();
|
||||
return cleaned
|
||||
.trim()
|
||||
.replace(/\u0000(\d+)\u0000/g, (_, index) => protectedTags[Number(index)]);
|
||||
}
|
||||
|
||||
export function applyLoraValuesToText(originalText, loras) {
|
||||
|
||||
Reference in New Issue
Block a user