Rich-Harris / magic-string

Manipulate strings like a wizard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected `.replace` behavior

fisker opened this issue · comments

> 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?

Seems to be a bug, PR welcome!