diff --git a/packages/workflow/src/tool-helpers.ts b/packages/workflow/src/tool-helpers.ts index 8d222de40f..bc410ad1d9 100644 --- a/packages/workflow/src/tool-helpers.ts +++ b/packages/workflow/src/tool-helpers.ts @@ -6,5 +6,5 @@ import type { INode } from './interfaces'; */ export function nodeNameToToolName(nodeOrName: INode | string): string { const name = typeof nodeOrName === 'string' ? nodeOrName : nodeOrName.name; - return name.replace(/[\s.?!=+#@&*()[\]{}:;,<>\/\\'"^%$_]+/g, '_'); + return name.replace(/[^a-zA-Z0-9_-]+/g, '_'); } diff --git a/packages/workflow/test/tool-helpers.test.ts b/packages/workflow/test/tool-helpers.test.ts index c0d98c5dcf..92a904bd4a 100644 --- a/packages/workflow/test/tool-helpers.test.ts +++ b/packages/workflow/test/tool-helpers.test.ts @@ -49,6 +49,18 @@ describe('nodeNameToToolName', () => { expect(nodeNameToToolName(getNodeWithName('Test#+*()[]{}:;,<>/\\\'"%$Node'))).toBe('Test_Node'); }); + it('should replace emojis with underscores', () => { + expect(nodeNameToToolName(getNodeWithName('Test 😀 Node'))).toBe('Test_Node'); + }); + + it('should replace multiple emojis with underscores', () => { + expect(nodeNameToToolName(getNodeWithName('🚀 Test 📊 Node 🎉'))).toBe('_Test_Node_'); + }); + + it('should handle complex emoji sequences', () => { + expect(nodeNameToToolName(getNodeWithName('Test 👨‍💻 Node 🔥'))).toBe('Test_Node_'); + }); + describe('when passed a string directly', () => { it('should replace spaces with underscores', () => { expect(nodeNameToToolName('Test Node')).toBe('Test_Node');