Unexpected `.replace` behavior
fisker opened this issue · comments
fisker Cheung commented
> new (require('magic-string'))('foo+bar').replace('foo\\.bar', 'replaced').toString()
'foo+bar'
> new (require('magic-string'))('foo+bar').replace('foo.bar', 'replaced').toString()
'replaced'
This behavior is unexpected to me. Why don't we use String#indexOf
instead of String#match
?
Anthony Fu commented
Seems to be a bug, PR welcome!