diff --git a/lib/index.js b/lib/index.js index 580b2de..e000c3a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,7 +28,7 @@ function doReplace(str, query, replacement) { return submatches[submatchIndex] }) var type = Case.of(match) - return type ? Case[type](match.replace(query, convertedReplacement)) : match.replace(query, convertedReplacement) + return type ? Case[type](convertedReplacement) : convertedReplacement }) } else { return str.replace(query, function (match) { diff --git a/test/index.js b/test/index.js index 58126c7..ef76417 100644 --- a/test/index.js +++ b/test/index.js @@ -24,10 +24,10 @@ describe('replace', function () { replace( ' foo bar FOO_BAR baz_bar fooBaz ', /(foo|bar|baz)[-_ ]?(foo|bar|baz)/i, - '$2 $1 $0 $3' + '$2 $1 $0$$$3' ) ).to.equal( - ' bar foo $0 $3 FOO_BAR baz_bar fooBaz ' + ' bar foo $0$$3 FOO_BAR baz_bar fooBaz ' ) expect(