feature(util) rm replaceStr

This commit is contained in:
coderaiser 2015-01-12 10:40:00 -05:00
parent a1daf8e884
commit c33435b692
3 changed files with 7 additions and 28 deletions

View file

@ -93,7 +93,7 @@ var Util, DOM, CloudFunc, CloudCmd;
* browser do not replace % -> %25%
* do it for him
*/
link = Util.replaceStr(link, '%%', '%25%');
link = link.replace('%%', '%25%');
link = decodeURI(link);
link = link.replace(CloudFunc.FS, '') || '/';

View file

@ -180,7 +180,7 @@ var Util, DOM, CloudFunc, CloudCmd;
* if we send ajax request -
* no need in hash so we escape #
*/
p.url = Util.replaceStr(p.url, '#', '%23');
p.url = p.url.replace('#', '%23');
DOM.load.ajax({
method : p.method,

View file

@ -220,28 +220,6 @@
};
}
/**
* function replase pFrom to pTo in pStr
* @param str
* @param from
* @param to
* @param notEscape
*/
this.replaceStr = function(str, from, to, notEscape) {
var regExp,
isStr = Util.type.string(str);
if (isStr && from) {
if (!notEscape)
from = Util.escapeRegExp(from);
regExp = new RegExp(from, 'g');
str = str.replace(regExp, to);
}
return str;
};
this.escapeRegExp = function(str) {
var isStr = Util.type.string(str);
@ -260,10 +238,11 @@
if (!wildcard)
wildcard = '*';
wildcard = '^' + wildcard; /* search from start of line */
wildcard = Util.replaceStr(wildcard, '.', '\\.');
wildcard = Util.replaceStr(wildcard, '*', '.*');
wildcard = Util.replaceStr(wildcard, '?', '.?\\');
wildcard = '^' + wildcard /* search from start of line */
.replace('.', '\\.')
.replace('*', '.*')
.replace('?', '.?\\');
wildcard += '$'; /* search to end of line */
regExp = new RegExp(wildcard);