diff --git a/source/util.js b/source/util.js index d617156..ca466fd 100644 --- a/source/util.js +++ b/source/util.js @@ -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); diff --git a/test/chalk.js b/test/chalk.js index 008a128..2992a09 100644 --- a/test/chalk.js +++ b/test/chalk.js @@ -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' ); });