Skip to content

Commit

Permalink
fix: mistake in special replacement pattern handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Aug 13, 2018
1 parent 259c189 commit 25f023e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 25f023e

Please sign in to comment.