fix(core): Fix expression extension misdetection (#5219)

* 🐛 Narrow down check

* fix: converted expression extension check loop into regex

* fix: remove greedy string check

* fix: re-add string spliting regex

Co-authored-by: Valya Bullions <valya@n8n.io>
This commit is contained in:
Iván Ovejero
2023-01-23 11:08:27 +01:00
committed by GitHub
parent c5245dd387
commit 0b123ce05e
2 changed files with 12 additions and 5 deletions

View File

@@ -314,11 +314,15 @@ export class Expression {
}
extendSyntax(bracketedExpression: string): string {
if (!hasExpressionExtension(bracketedExpression) || hasNativeMethod(bracketedExpression))
return bracketedExpression;
const chunks = splitExpression(bracketedExpression);
const codeChunks = chunks
.filter((c) => c.type === 'code')
.map((c) => c.text.replace(/("|').*?("|')/, '').trim());
if (!codeChunks.some(hasExpressionExtension) || hasNativeMethod(bracketedExpression))
return bracketedExpression;
const extendedChunks = chunks.map((chunk): ExpressionChunk => {
if (chunk.type === 'code') {
const output = extendTransform(chunk.text);