Skip to content

Conversation

@jonaskohl
Copy link

This fixes an issue where the needle string would be used in a regex without escaping, thus yielding unexpected results

@cferdinandi
Copy link
Owner

Hi @jonaskohl - thanks for this!

The only change I'd suggest is removing the function abstraction and include the String.replace() function write in the new RegExp() constructor.

return this.replace(new RegExp(str.replace(/[.*+?(){}^$|[\]\\]/g, '\\$&'), 'g'), newStr);

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 this pull request may close these issues.

2 participants