mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
Merge 75da839d93 into 0ce820de73
This commit is contained in:
commit
15aa9fb429
|
|
@ -25,6 +25,12 @@ const normalizeBackslashes = (text: string): string => {
|
|||
};
|
||||
|
||||
export const splitExpression = (expression: string): ExpressionChunk[] => {
|
||||
// Maintain the "always have an initial text chunk" invariant
|
||||
// that ExpressionBuilder.getExpressionCode relies on.
|
||||
if (expression === '') {
|
||||
return [{ type: 'text', text: '' }];
|
||||
}
|
||||
|
||||
const chunks: ExpressionChunk[] = [];
|
||||
let searchingFor: 'open' | 'close' = 'open';
|
||||
let activeRegex = OPEN_BRACKET;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ export const escapeCode = (text: string): string => {
|
|||
};
|
||||
|
||||
export const splitExpression = (expression: string): ExpressionChunk[] => {
|
||||
// Mirror @n8n/tournament's splitExpression: always emit an initial text
|
||||
// chunk so downstream consumers can rely on chunks[0] being defined.
|
||||
if (expression === '') {
|
||||
return [{ type: 'text', text: '' }];
|
||||
}
|
||||
|
||||
const chunks: ExpressionChunk[] = [];
|
||||
let searchingFor: 'open' | 'close' = 'open';
|
||||
let activeRegex = OPEN_BRACKET;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,10 @@ describe('Expression Parser', () => {
|
|||
{ type: 'code', text: ' code.test("}}") ', hasClosingBrackets: true },
|
||||
]);
|
||||
});
|
||||
|
||||
test('Empty input (CAT-3075)', () => {
|
||||
expect(splitExpression('')).toEqual([{ type: 'text', text: '' }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Compatible joining', () => {
|
||||
|
|
|
|||
|
|
@ -778,6 +778,14 @@ describe('Expression', () => {
|
|||
});
|
||||
});
|
||||
|
||||
// CAT-3075: feature parity between legacy and VM engines for empty expressions.
|
||||
// The legacy engine returns "" via Tournament.execute's empty-input guard;
|
||||
// the VM engine bypassed that guard and threw
|
||||
// `TypeError: Cannot read properties of undefined (reading 'text')`.
|
||||
it('should resolve "=" (empty expression marker) to "" (CAT-3075)', () => {
|
||||
expect(evaluate('=')).toBe('');
|
||||
});
|
||||
|
||||
describe('additionalKeys', () => {
|
||||
const node = workflow.nodes.node;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user