Skip to content

Commit 56a58a8

Browse files
committed
chore(builtins): adopt unified pattern parsing for split function
Related to #96
1 parent 08f46e0 commit 56a58a8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/builtins.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ const builtins = {
387387
}, [ 'string', 'string' ]),
388388

389389
'split': fn(function(string, delimiter) {
390-
return string.split(new RegExp(delimiter, 'u'));
390+
const regexp = createRegexp(delimiter, '', '');
391+
392+
return regexp && string.split(regexp);
391393
}, [ 'string', 'string' ]),
392394

393395
'string join': fn(function(list, delimiter) {

test/builtins-spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ describe('builtin functions', function() {
274274

275275
expr('split(string: "foo🐎bar", delimiter: "o.b")', [ 'fo', 'ar' ]);
276276

277+
expr('split("foo bar", "[a-z")', null);
278+
277279
expr('string join(123, "X")', null);
278280

279281
expr('string join(123, "X")', null);

0 commit comments

Comments
 (0)