diff --git a/libraries/botframework-expressions/src/builtInFunction.ts b/libraries/botframework-expressions/src/builtInFunction.ts index 2f2dbd7e0a..8a2767a1a0 100644 --- a/libraries/botframework-expressions/src/builtInFunction.ts +++ b/libraries/botframework-expressions/src/builtInFunction.ts @@ -1895,9 +1895,9 @@ export class BuiltInFunctions { (expression: Expression): void => BuiltInFunctions.validateArityAndAnyType(expression, 3, 3, ReturnType.String)), new ExpressionEvaluator( ExpressionType.Split, - BuiltInFunctions.apply((args: any []): string[] => BuiltInFunctions.parseStringOrNull(args[0]).split(BuiltInFunctions.parseStringOrNull(args[1])), BuiltInFunctions.verifyStringOrNull), + BuiltInFunctions.apply((args: any []): string[] => BuiltInFunctions.parseStringOrNull(args[0]).split(BuiltInFunctions.parseStringOrNull(args[1]? args[1]: '')), BuiltInFunctions.verifyStringOrNull), ReturnType.Object, - (expression: Expression): void => BuiltInFunctions.validateArityAndAnyType(expression, 2, 2, ReturnType.String)), + (expression: Expression): void => BuiltInFunctions.validateArityAndAnyType(expression, 1, 2, ReturnType.String)), new ExpressionEvaluator( ExpressionType.Substring, BuiltInFunctions.substring, diff --git a/libraries/botframework-expressions/tests/badExpression.test.js b/libraries/botframework-expressions/tests/badExpression.test.js index 21514c7980..31f32ed5bb 100644 --- a/libraries/botframework-expressions/tests/badExpression.test.js +++ b/libraries/botframework-expressions/tests/badExpression.test.js @@ -46,7 +46,7 @@ const badExpressions = 'replaceIgnoreCase(one, \'l\', \'k\')', // replaceIgnoreCase only accept string parameter 'replaceIgnoreCase(\'hi\', 1, \'k\')', // replaceIgnoreCase only accept string parameter 'replaceIgnoreCase(\'hi\', \'l\', 1)', // replaceIgnoreCase only accept string parameter - 'split(hello)', // split need two parameters + 'split(hello, \'l\', \'l\')', // split need one or two parameters 'split(one, \'l\')', // split only accept string parameter 'split(hello, 1)', // split only accept string parameter 'substring(hello, 0.5)', // the second parameter of substring must be integer diff --git a/libraries/botframework-expressions/tests/expression.test.js b/libraries/botframework-expressions/tests/expression.test.js index 598a3e32fe..e30e5a8949 100644 --- a/libraries/botframework-expressions/tests/expression.test.js +++ b/libraries/botframework-expressions/tests/expression.test.js @@ -93,6 +93,7 @@ const dataSource = [ ['replaceIgnoreCase(nullObj, \'L\', \'k\')', ''], ['replaceIgnoreCase(\'hello\', \'L\', nullObj)', 'heo'], ['split(\'hello\',\'e\')', ['h', 'llo']], + ['split(\'hello\')', ['h', 'e', 'l', 'l', 'o']], ['split(nullObj,\'e\')', ['']], ['split(\'hello\',nullObj)', ['h', 'e', 'l', 'l', 'o']], ['split(nullObj,nullObj)', []],