refac
This commit is contained in:
@@ -1411,6 +1411,22 @@ export const slugify = (str: string): string => {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a display name into a safe, underscore-delimited identifier.
|
||||
* Strips emojis, accents, and any non-alphanumeric characters so the
|
||||
* result is always accepted by backend validation.
|
||||
*
|
||||
* e.g. "My Tool 😄" → "my_tool"
|
||||
*/
|
||||
export const nameToId = (name: string): string => {
|
||||
return name
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.replace(/[^\w]+/g, '_')
|
||||
.replace(/^_+|_+$/g, '')
|
||||
.toLowerCase();
|
||||
};
|
||||
|
||||
export const extractInputVariables = (text: string): Record<string, any> => {
|
||||
const regex = /{{\s*([^|}\s]+)\s*\|\s*([^}]+)\s*}}/g;
|
||||
const regularRegex = /{{\s*([^|}\s]+)\s*}}/g;
|
||||
|
||||
Reference in New Issue
Block a user