mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(editor): UI enhancements and fixes for expression inputs (#8996)
This commit is contained in:
@@ -382,7 +382,10 @@ function parseJson(value: string): unknown {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
if (value.includes("'")) {
|
||||
throw new ExpressionExtensionError("Parsing failed. Check you're using double quotes");
|
||||
}
|
||||
throw new ExpressionExtensionError('Parsing failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,13 @@ describe('Data Transformation Functions', () => {
|
||||
test1: 1,
|
||||
test2: '2',
|
||||
});
|
||||
expect(evaluate('={{ "hi".parseJson() }}')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('.parseJson should throw on invalid JSON', () => {
|
||||
expect(() => evaluate("={{ \"{'test1':1,'test2':'2'}\".parseJson() }}")).toThrowError(
|
||||
"Parsing failed. Check you're using double quotes",
|
||||
);
|
||||
expect(() => evaluate('={{ "No JSON here".parseJson() }}')).toThrowError('Parsing failed');
|
||||
});
|
||||
|
||||
test('.toBoolean should work on a string', () => {
|
||||
|
||||
Reference in New Issue
Block a user