Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected .replace behavior #221

Closed
fisker opened this issue Sep 7, 2022 · 1 comment · Fixed by #222
Closed

Unexpected .replace behavior #221

fisker opened this issue Sep 7, 2022 · 1 comment · Fixed by #222

Comments

@fisker
Copy link
Contributor

fisker commented Sep 7, 2022

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

@antfu
Copy link
Collaborator

antfu commented Sep 7, 2022

Seems to be a bug, PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants