Skip to content

Commit

Permalink
Fix support for nested styles (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored and sindresorhus committed Jul 12, 2019
1 parent c25c32a commit 87156ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/util.js
Expand Up @@ -10,7 +10,7 @@ const stringReplaceAll = (string, substring, replacer) => {
let endIndex = 0;
let returnValue = '';
do {
returnValue += string.substr(endIndex, index - endIndex) + replacer;
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
endIndex = index + substringLength;
index = string.indexOf(substring, endIndex);
} while (index !== -1);
Expand Down
2 changes: 1 addition & 1 deletion test/chalk.js
Expand Up @@ -37,7 +37,7 @@ test('support nesting styles', t => {
test('support nesting styles of the same type (color, underline, bg)', t => {
t.is(
chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'),
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[33mb\u001B[31mc\u001B[39m'
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[39m\u001B[31m\u001B[33mb\u001B[39m\u001B[31mc\u001B[39m'
);
});

Expand Down

0 comments on commit 87156ce

Please sign in to comment.