diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 9992adf..ba6840b 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -61,17 +61,25 @@ ); // Match backend's sanitize_folder_name logic for video path construction + // Must exactly replicate src/utils.rs sanitize_folder_name function sanitizeFolderName(name, id) { const base = name && name.trim() ? name : id; + + // Remove accents by decomposing to NFD and filtering combining marks + const withoutAccents = base.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + + // Convert to lowercase and replace unsafe characters with underscores let sanitized = ''; - for (const c of base) { - if (/^[\p{L}\p{N}\-_ ]$/u.test(c)) { + for (const c of withoutAccents.toLowerCase()) { + if (/^[a-z0-9\-_]$/.test(c)) { sanitized += c; } else { sanitized += '_'; } } - sanitized = sanitized.trim(); + + // Trim whitespace and underscores, then limit length + sanitized = sanitized.replace(/^[\s_]+|[\s_]+$/g, ''); return sanitized.length > 50 ? sanitized.slice(0, 50) : sanitized; } diff --git a/frontend/src/lib/components/ProcessingControls.svelte b/frontend/src/lib/components/ProcessingControls.svelte index ed5722d..ff7a1c8 100644 --- a/frontend/src/lib/components/ProcessingControls.svelte +++ b/frontend/src/lib/components/ProcessingControls.svelte @@ -11,19 +11,25 @@ ); // Match backend's sanitize_folder_name logic - // Uses Unicode-aware regex to match Rust's is_alphanumeric() + // Must exactly replicate src/utils.rs sanitize_folder_name function sanitizeFolderName(name, id) { const base = name && name.trim() ? name : id; + + // Remove accents by decomposing to NFD and filtering combining marks + const withoutAccents = base.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + + // Convert to lowercase and replace unsafe characters with underscores let sanitized = ''; - for (const c of base) { - // \p{L} = Unicode letter, \p{N} = Unicode number (matches Rust's is_alphanumeric) - if (/^[\p{L}\p{N}\-_ ]$/u.test(c)) { + for (const c of withoutAccents.toLowerCase()) { + if (/^[a-z0-9\-_]$/.test(c)) { sanitized += c; } else { sanitized += '_'; } } - sanitized = sanitized.trim(); + + // Trim whitespace and underscores, then limit length + sanitized = sanitized.replace(/^[\s_]+|[\s_]+$/g, ''); return sanitized.length > 50 ? sanitized.slice(0, 50) : sanitized; }