Fix handling of Japanese characters in custom field blocks

[STOMAIL-7383]
This commit is contained in:
Pavel Dohnal
2025-04-29 12:53:24 +02:00
committed by Aschepikov
parent 5c7a746470
commit 54359dc610

View File

@ -1,8 +1,15 @@
import slugify from 'slugify';
export function formatCustomFieldBlockName(blockName, customField) {
const name = slugify(customField.name, { lower: true })
let name = slugify(customField.name, { lower: true })
.replace(/[^a-z0-9]+/g, '')
.replace(/-$/, '');
// Ensure unique block names by appending ID if the slug is empty or too short
// (which can happen with certain character sets)
if (!name || name.length < 2) {
name = `field${customField.id}`;
}
return `${blockName}-${name}`;
}