fix(util) replaceStr: escape before create

This commit is contained in:
coderaiser 2014-05-12 09:02:16 -04:00
parent 757a85bee9
commit 0093c8e650

View file

@ -494,14 +494,15 @@
* @param notEscape
*/
this.replaceStr = function(str, from, to, notEscape) {
var isStr = Util.isString(str),
regExp = new RegExp(from, 'g');
var regExp,
isStr = Util.isString(str);
if (isStr && from) {
if (!notEscape)
from = Util.escapeRegExp(from);
str = str.replace(regExp, to);
regExp = new RegExp(from, 'g');
str = str.replace(regExp, to);
}
return str;