var len = value.length;
var tokens = [];
- while (cursor++ < len) {
+ while (cursor < len) {
if (value[cursor] == openLevel) {
level++;
} else if (value[cursor] == closeLevel) {
level--;
}
- if ((withRegex ? separator.test(value[cursor]) : value[cursor] == separator) && level === 0) {
+ if (level === 0 && cursor > 0 && cursor + 1 < len && (withRegex ? separator.test(value[cursor]) : value[cursor] == separator)) {
tokens.push(value.substring(lastStart, cursor + (includeSeparator ? 1 : 0)));
lastStart = cursor + 1;
}
+
+ cursor++;
}
if (lastStart < cursor + 1)
'with custom wrappers - on close brace': {
topic: 'a{ color:red; --var { color:red; display: none } } p{ color:red }',
split: function (input) {
- assert.deepEqual(split(input, '}', true, '{', '}'), [ 'a{ color:red; --var { color:red; display: none } }', ' p{ color:red }', '' ]);
+ assert.deepEqual(split(input, '}', true, '{', '}'), [ 'a{ color:red; --var { color:red; display: none } }', ' p{ color:red }' ]);
+ }
+ },
+ 'with custom wrappers - one block on close brace': {
+ topic: '{ color:red; --var { color:red; display: none } color:blue }',
+ split: function (input) {
+ assert.deepEqual(split(input, '}', true, '{', '}'), [ '{ color:red; --var { color:red; display: none } color:blue }' ]);
}
}
})